随笔分类 -  数论

摘要:Jason买来了n米长的竹篱笆,打算将n米长的竹篱笆全部用来围成一个三角形的养鸡场。为方便起见,养鸡场三条边的长度都为正整数。同时,他想让自己的养鸡场看起来更美观一些,要求三条边的长度分别在一个区间范围内。 现在,他想知道有多少种不同的方案使得围成的养鸡场满足要求? 输入包含多组数据。输入数据第一行 阅读全文
posted @ 2013-09-17 21:36 1002liu 阅读(320) 评论(0) 推荐(0)
摘要:子序列的定义:对于一个序列a=a[1],a[2],......a[n]。则非空序列a'=a[p1],a[p2]......a[pm]为a的一个子序列,其中1<=p1<p2<.....<pm<=n。 例如4,14,2,3和14,1,2,3都为4,13,14,1,2,3的子序列。 对于给出序列a,请输出 阅读全文
posted @ 2013-09-17 21:33 1002liu 阅读(275) 评论(0) 推荐(0)
摘要:福州大学第十届程序设计竞赛 阅读全文
posted @ 2013-09-17 20:28 1002liu 阅读(184) 评论(0) 推荐(0)
摘要:23 3 31 3 21 2 12 3 11 3 3 3 3 31 3 21 2 22 3 21 3 4 阅读全文
posted @ 2013-09-13 19:42 1002liu 阅读(255) 评论(0) 推荐(0)
摘要:Problem Description If we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number.You are requ 阅读全文
posted @ 2013-09-11 19:28 1002liu 阅读(218) 评论(0) 推荐(0)
摘要:求区间[a,b]包含1的数量。例如区间[111,112], 整个区间包含两个数,分别为111,112,111包含3个1,而112包含2个1,所以区间[111,112]总共包含5个1 多组测试数据。 每组测试数据包含两个整数a, b, 1 <= a <= b <= 10^18. 每组测试输出一行,表示 阅读全文
posted @ 2013-09-10 21:25 1002liu 阅读(241) 评论(0) 推荐(0)
摘要:13 32 2 31 1 3 41 2 3 6 阅读全文
posted @ 2013-09-06 14:08 1002liu 阅读(171) 评论(0) 推荐(0)
摘要:任意一个分数都是有理数,对于任意一个有限小数,我们都可以表示成一个无限循环小数的形式(在其末尾添加0),对于任意一个无限循环小数都可以转化成一个分数。现在你的任务就是将任意一个无限循环小数转化成既约分数形式。所谓既约分数表示,分子和分母的最大公约数是1。 有多组数据。 每组数据一行。输入为0.a1a 阅读全文
posted @ 2013-09-05 09:42 1002liu 阅读(226) 评论(0) 推荐(0)
摘要:每组输出一行为 Case 组号: 答案,即M时刻活着的小宠物个数%10000 阅读全文
posted @ 2013-09-03 22:46 1002liu 阅读(184) 评论(0) 推荐(0)
摘要:Problem Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbers the boxes from 0 to A-1. To find the balls easily, he puts the ball numbered x into the box numbered ... 阅读全文
posted @ 2013-08-05 23:35 1002liu 阅读(204) 评论(0) 推荐(0)
摘要:There is a straight highway with N storages alongside it labeled by 1,2,3,...,N. Bob asks you to paint all storages with two colors: red and blue. Eac 阅读全文
posted @ 2013-08-05 23:31 1002liu 阅读(221) 评论(0) 推荐(0)
摘要:Problem Description Let f(x) = anxn +...+ a1x +a0, in which ai (0 = 3, otherwise abs(ai) 2 typedef long long ll; 3 4 ll a[10],b[10010]; 5 ll f(ll n,ll x) 6 { 7 if(n==0) return a[0]; 8 ... 阅读全文
posted @ 2013-06-06 21:59 1002liu 阅读(208) 评论(0) 推荐(0)
摘要:Problem Description A sequence Sn is defined as:Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example, ┌3.14┐=4. You are to calculate Sn. You, a top coder, say: So easy! Input ... 阅读全文
posted @ 2013-06-03 17:49 1002liu 阅读(249) 评论(0) 推荐(0)
摘要:/**********************欧几里得算法***********************/其实很早就知道这个东西了。。也就是以前所说的辗转相除法求最大公约数。GCD(a,b)=GCD(b,a mod b)稍微证明一下:(参考:算法导论)证明的思路是大致是这样的:证明 GCD(a,b) 阅读全文
posted @ 2013-05-20 23:18 1002liu 阅读(468) 评论(0) 推荐(0)
摘要:Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in com 阅读全文
posted @ 2013-05-19 00:11 1002liu 阅读(158) 评论(0) 推荐(0)