随笔分类 -  数学问题

摘要:给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。 1 class Solution { 2 public: 3 double Power(double base, int exponent) { 4 if (exp... 阅读全文
posted @ 2016-01-21 17:00 小爷 阅读(136) 评论(0) 推荐(0)
摘要:题目描述大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项。 1 class Solution { 2 public: int Fibonacci(int n) { 5 if (n ==0 || n ==1) 6 return... 阅读全文
posted @ 2016-01-21 16:20 小爷 阅读(158) 评论(0) 推荐(0)
摘要:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is... 阅读全文
posted @ 2015-02-28 10:55 小爷 阅读(203) 评论(0) 推荐(0)
摘要:时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven N rational numbers in the form "numerator/denominator", you are supposed to calculate ... 阅读全文
posted @ 2015-02-13 16:09 小爷 阅读(245) 评论(0) 推荐(0)
摘要:时间限制50 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者HE, QinmingGiven any positive integer N, you are supposed to find all of its prime factors, and write ... 阅读全文
posted @ 2015-02-07 23:54 小爷 阅读(255) 评论(0) 推荐(0)
摘要:时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven an increasing sequence S of N integers, themedianis the number at the middle position.... 阅读全文
posted @ 2015-02-06 09:18 小爷 阅读(270) 评论(0) 推荐(0)
摘要:A + B分数: 1.8时间限制:1 秒内存限制:32 兆特殊判题:否提交:171解决:85标签A+B字符串与数字对应字符串处理题目描述读入两个小于100的正整数A和B,计算A+B.需要注意的是:A和B的每一位数字由对应的英文单词给出.输入格式测试输入包含若干测试用例,每个测试用例占一行,格式为"A... 阅读全文
posted @ 2015-02-06 07:38 小爷 阅读(448) 评论(0) 推荐(0)
摘要:1 #include 2 int main() 3 { 4 int ans1[3]; 5 int ans2[3]; 6 while(scanf("%d.%d.%d %d.%d.%d",&ans1[0],&ans1[1],&ans1[2],&ans2[0],&ans2[1],&a... 阅读全文
posted @ 2015-01-31 23:45 小爷 阅读(163) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { 8 string str; 9 char num[10][6]={"zero","one","two","three","f... 阅读全文
posted @ 2015-01-31 23:37 小爷 阅读(129) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 int main() 4 { 5 long long a,b,c,sum; 6 int n,i; 7 while(scanf("%d",&n)!=EOF) 8 { 9 for(i=1;i0&&b>0... 阅读全文
posted @ 2015-01-31 23:32 小爷 阅读(182) 评论(0) 推荐(0)
摘要:时间限制400 ms内存限制32000 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThis time, you are supposed to find A+B where A and B are two polynomials.InputEach input fi... 阅读全文
posted @ 2015-01-31 07:34 小爷 阅读(156) 评论(0) 推荐(0)
摘要:With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing ba... 阅读全文
posted @ 2015-01-30 07:43 小爷 阅读(197) 评论(0) 推荐(0)
摘要:Areversibleprimeinanynumbersystemisaprimewhose"reverse"inthatnumbersystemisalsoaprime.Forexampleinthedecimalsystem73isareversibleprimebecauseitsrevers... 阅读全文
posted @ 2015-01-30 07:40 小爷 阅读(264) 评论(0) 推荐(0)
摘要:交换 int a, int b1、最弱的方法1 void swap(int &a,int &b)2 {3 int c = a;4 a = b;5 b = c;6 }2、不用另外开辟空间的方法1 void swap(int &a,int &b)2 {3 a=a+b;4 ... 阅读全文
posted @ 2015-01-29 08:18 小爷 阅读(292) 评论(0) 推荐(0)
摘要:1 #include 2 int getbit( int a,int i) 3 { 4 return a&(1 if(n&1 == 0) n/=pow(2,x) ----> n >>= x n*=pow(2,x) ----> n <<= x|或(或1为1) 阅读全文
posted @ 2015-01-29 07:42 小爷 阅读(250) 评论(0) 推荐(0)
摘要:A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number... 阅读全文
posted @ 2015-01-28 13:35 小爷 阅读(240) 评论(0) 推荐(0)
摘要:A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number... 阅读全文
posted @ 2015-01-22 07:28 小爷 阅读(310) 评论(0) 推荐(0)
摘要:Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 2469135... 阅读全文
posted @ 2015-01-22 07:26 小爷 阅读(474) 评论(0) 推荐(0)