随笔分类 -  数论

摘要:DescriptionGiven a big integer number, you are required to find out whether it's a prime number.InputThe first line contains the number of test cases ... 阅读全文
posted @ 2014-11-16 21:46 Oyking 阅读(309) 评论(0) 推荐(0)
摘要:Problem DescriptionAlthough winter is far away, squirrels have to work day and night to save beans. They need plenty of food to get through those long... 阅读全文
posted @ 2014-11-16 16:21 Oyking 阅读(290) 评论(0) 推荐(0)
摘要:In mathematical terms, the sequenceFnof Fibonacci numbers is defined by the recurrence relationF1 = 1;F2 = 1;Fn = Fn - 1 + Fn - 2(n > 2).DZY loves Fib... 阅读全文
posted @ 2014-07-16 14:46 Oyking 阅读(799) 评论(0) 推荐(0)
摘要:Problem Description一个{1, ..., n}的子集S被称为JZP集,当且仅当对于任意S中的两个数x,y,若(x+y)/2为整数,那么(x+y)/2也属于S。例如,n=3,S={1,3}不是JZP集,因为(1+3)/2=2不属于S。但是{1,2,3}的其他子集都属于S,所以n=3时... 阅读全文
posted @ 2014-05-25 21:17 Oyking 阅读(662) 评论(0) 推荐(0)
摘要:DescriptionLittle Y finds there is a very interesting formula in mathematics:XYmod Z = KGivenX,Y,Z, we all know how to figure outKfast. However, givenX,Z,K, could you figure outYfast?InputInput data consists of no more than 20 test cases. For each test case, there would be only one line containing 3 阅读全文
posted @ 2014-03-29 23:27 Oyking 阅读(348) 评论(0) 推荐(0)
摘要:DescriptionGiven a prime P, 2 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 typedef long long LL; 8 9 const int SIZEH = 65537;10 11 struct hash_map {12 int head[SIZEH], size;13 int next[SIZEH];14 LL state[SIZEH], val[SIZEH];15 16 void init() {17 m... 阅读全文
posted @ 2014-03-28 21:29 Oyking 阅读(550) 评论(0) 推荐(0)
摘要:The blocks in the city of Fishburg are of square form.Navenues running south to north andMstreets running east to west bound them. A helicopter took off in the most southwestern crossroads and flew along the straight line to the most northeastern crossroads. How many blocks did it fly above?Note.A b 阅读全文
posted @ 2014-03-01 18:43 Oyking 阅读(366) 评论(0) 推荐(0)
摘要:DescriptionElina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as foll... 阅读全文
posted @ 2014-02-12 23:13 Oyking 阅读(241) 评论(0) 推荐(0)
摘要:Problem Description Let f(x) = anxn+...+ a1x +a0, in which ai(0 = 3, otherwise abs(ai) 2 #include 3 #include 4 #include 5 using namespace std; 6 typedef long long LL; 7 8 const int MAXN = 8; 9 10 int T, deg;11 LL phi;12 LL a[MAXN];13 14 LL f(LL x, LL m) {15 LL ret = 0, xx = 1;16 for(in... 阅读全文
posted @ 2013-08-22 14:25 Oyking 阅读(468) 评论(5) 推荐(0)
摘要:1、求逆元1 int inv(int a) {2 if(a == 1) return 1;3 return (MOD - MOD / a) * inv(MOD % a);4 }View Code 2、线性筛法 1 bool isPrime[MAXN]; 2 int label[MAX... 阅读全文
posted @ 2013-08-19 23:14 Oyking 阅读(269) 评论(0) 推荐(0)
摘要:一、代码: 1、求逆元(原理貌似就是拓展欧几里得,要求MOD是素数): 2、底层优化(正确性未验证): 3、扩栈,这玩意儿在OJ上用能防爆? 4、神速读入fread 二、神牛blog matrix67 ZKW watashi 三、专题 动态规划系列: 数位dp模板 字符串系列: 【专辑】AC自动机 阅读全文
posted @ 2013-08-14 23:48 Oyking 阅读(1316) 评论(0) 推荐(0)
摘要:DescriptionKitty is a little cat. She is crazy about a game recently.There arenscenes in the game(mark from 1 ton). Each scene has a numberpi. Kitty's score will become least_common_multiple(x,pi) when Kitty enter theithscene.xis the score that Kitty had previous. Notice that Kitty will become m 阅读全文
posted @ 2013-08-13 17:43 Oyking 阅读(283) 评论(0) 推荐(0)
摘要:You have been givenndistinct integersa1, a2, ..., an. You can remove at mostkof them. Find the minimum modularm(m > 0), so that for every pair of the remaining integers(ai, aj), the following unequality holds:.InputThe first line contains two integersnandk(1 ≤ n ≤ 5000, 0 ≤ k ≤ 4), which we have 阅读全文
posted @ 2013-07-06 00:04 Oyking 阅读(399) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 using namespace std; 4 5 bool isPrime[1000000]; 6 int prime[1000000]; 7 int MAX, total, cnt; 8 ... 阅读全文
posted @ 2013-06-04 10:47 Oyking 阅读(438) 评论(0) 推荐(0)