【题目】
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
【分析】
这个和上篇博文中把数字转换为罗马数字正好相反,逻辑过程有点儿复杂。
其实解法来源于对罗马数字(字符串)的观察,...
分类:
其他好文 时间:
2015-05-06 23:07:28
阅读次数:
180
Number PuzzleTime Limit: 2 Seconds Memory Limit: 65536 KBGiven a list of integers (A1, A2, ..., An), and a positive integer M, please find the number ...
分类:
其他好文 时间:
2015-05-06 19:31:00
阅读次数:
106
Farmer John has just given the cows a program to play with! The program contains two integer variables, x and y, and performs the following operations on a sequence a1,?a2,?…,?an of positive integers:I...
分类:
其他好文 时间:
2015-05-06 17:55:05
阅读次数:
187
【题目】 Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Some hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of co...
分类:
其他好文 时间:
2015-05-06 13:26:23
阅读次数:
115
#include
using namespace std;
template
T power(T x,Integer n)
{
if(n == 0) return 1;
if(n == 1) return x;
while((n&1) == 0)
{
x = x*x;
n >>= 1;
}
T result = x...
分类:
其他好文 时间:
2015-05-06 13:18:36
阅读次数:
125
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer...
分类:
移动开发 时间:
2015-05-06 10:54:56
阅读次数:
146
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express...
分类:
其他好文 时间:
2015-05-05 23:46:55
阅读次数:
180
基本类型C/C++语言有一组基本类型,对应于计算机的基本存储单元和使用这些单元去保存数据的一些常用方式:基本数据类型如下:NameDescriptionSize*Range*charCharacter or small integer.1bytesigned: -128 to 127unsigned...
分类:
编程语言 时间:
2015-05-05 23:44:06
阅读次数:
196
题目:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below a...
分类:
其他好文 时间:
2015-05-05 21:33:48
阅读次数:
193
Number of 1 BitsTotal Accepted:25965Total Submissions:70075My SubmissionsQuestionSolutionWrite a function that takes an unsigned integer and returns t...
分类:
其他好文 时间:
2015-05-05 21:14:37
阅读次数:
124