ACM-数论
寻找星空的孩子
CSDN博客首页:http://blog.csdn.net/u010579068?viewmode=list
博客园地址:http://www.cnblogs.com/yuyixingkong/
展开
-
SPOJ4491. Primes in GCD Table(gcd(a,b)=d素数,(1<=a<=n,1<=b<=m))加强版
SPOJ4491. Primes in GCD Table Problem code: PGCD Johnny has created a table which encodes the results of some operation -- a function of two arguments. But instead of a boring mu原创 2015-08-22 12:52:50 · 1704 阅读 · 0 评论 -
Chinese remainder theorem again(中国剩余定理+不互质版+hud1788)
Chinese remainder theorem againTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 1788Appoint description: System Crawler (2015-04-原创 2015-05-02 18:39:33 · 1604 阅读 · 0 评论 -
C Looooops(欧几里德+poj2115)
C LooooopsDescriptionA Compiler Mystery: We are given a C-language style for loop of type for (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to value A and while variable is not equal to B, repe原创 2015-05-02 17:35:21 · 3274 阅读 · 5 评论 -
X问题(中国剩余定理应用)
X问题Problem Description求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], …, X mod a[i] = b[i], … (0 < a[i] <= 10)。原创 2015-05-02 16:00:18 · 1452 阅读 · 0 评论 -
Hello Kiki(hdu3579+不互质的中国剩余定理)
Hello KikiTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 3579Appoint description: System Crawler (2015-04-29)Description原创 2015-05-01 22:51:02 · 2237 阅读 · 0 评论 -
Modular Inverse(zoj3609+欧几里德)
Modular Inverse,zoj3609,欧几里德,The 9th Zhejiang Provincial Collegiate Programming Contest,The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent to ax≡1 (mod m).原创 2015-04-27 20:27:14 · 1242 阅读 · 0 评论 -
Cylinder Candy(积分+旋转体)
Cylinder CandyTime Limit: 2 Seconds Memory Limit: 65536 KB Special JudgeEdward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinde原创 2015-04-16 21:54:11 · 1345 阅读 · 0 评论 -
青蛙的约会(poj1061+欧几里德+同余方程)
**青蛙的约会**Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 94174 Accepted: 17412 Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要原创 2015-03-27 19:34:24 · 4786 阅读 · 1 评论 -
Romantic(hdu2699+欧几里德)
RomanticTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3218 Accepted Submission(s): 1274Problem Description The Sky is Sprite. The Birds原创 2015-03-26 13:21:09 · 1056 阅读 · 0 评论 -
Biorhythms(poj1006欧几里德)
BiorhythmsTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 117973 Accepted: 37026 DescriptionSome people believe that there are three cycles in a person’s life that start the day原创 2015-03-25 22:02:41 · 760 阅读 · 0 评论 -
扩展欧几里德求逆元模板
扩展欧几里德求逆元模板:#include<iostream>#define __int64 long longusing namespace std;//举例 3x+4y=1 ax+by=1//得到一组解x0=-1,y0=1 通解为x=-1+4k,y=1-3kinline __int64 extend_gcd(__int64 a,__int64 b,__int64 &x,__int64转载 2015-03-23 22:55:52 · 1002 阅读 · 0 评论 -
Bell(矩阵快速幂+中国剩余定理)
BellTime Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 4767Appoint description: System Crawler (2015-03-15)DescriptionWhat? M原创 2015-03-23 11:33:05 · 712 阅读 · 0 评论 -
Power of Matrix(uva11149+矩阵快速幂)
Power of MatrixTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVA 11149Appoint description: System Crawler (2015-03-15)Description原创 2015-03-23 11:33:01 · 706 阅读 · 0 评论 -
233 Matrix(hdu5015 矩阵)
233 MatrixTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1190 Accepted Submission(s): 700Problem DescriptionIn our daily life we ofte原创 2015-03-23 11:32:51 · 774 阅读 · 0 评论 -
Strange Way to Express Integers(中国剩余定理+不互质)
Strange Way to Express IntegersTime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64uSubmit Status Practice POJ 2891Appoint description: System Crawler (2015-04原创 2015-05-03 00:26:05 · 2382 阅读 · 0 评论 -
Bell(hdu4767+矩阵+中国剩余定理)
BellTime Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 4767 DescriptionWhat? MMM is learning Combinatorics!? Looks like she原创 2015-05-08 23:52:32 · 1095 阅读 · 0 评论 -
CRB and Candies(lcm(C(n,0)..C(n,n)=lcm(1,2,,,n+1)/(n+1)))hdu5407
CRB and CandiesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 358 Accepted Submission(s): 160Problem Description CRB has N d原创 2015-08-21 14:07:15 · 1665 阅读 · 0 评论 -
bzoj 2818 Gcd(莫比乌斯+gcd(a,b)=d) 经典
2818: GcdDescription给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对.原创 2015-08-19 20:28:44 · 2960 阅读 · 0 评论 -
取(2堆)石子游戏(威佐夫博弈+hdu2177)
Problem Description有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。如果你胜,你第1次怎样取子?原创 2015-08-05 23:38:17 · 1033 阅读 · 1 评论 -
Coins(2015嘉杰信息杯+dp)
CoinsProblem Description:Duoxida buys a bottle of MaiDong from a vending machine and the machine give her n coins back. She places them in a line randomly showing head face or tail face on. And Duoxida wants to know how many situations that m continuou原创 2015-08-05 23:47:00 · 862 阅读 · 1 评论 -
邂逅明下(巴什博弈+hdu2897)
H - 邂逅明下Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u每行有三个数字n,p,q,表示一堆硬币一共有n枚,从这个硬币堆里取硬币,一次最少取p枚,最多q枚,如果剩下少于p枚就要一次取完。两人轮流取,直到堆里的硬币取完,最后一次取硬币的算输。对于每一行的三个数字,给出先取的人是否有必胜策略,如果有回答WIN,否则回答LOST。原创 2015-08-06 11:19:47 · 943 阅读 · 1 评论 -
取石子游戏(hdu1527+威佐夫博弈)
Problem Description有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。如果你胜,你第1次怎样取子?原创 2015-08-05 23:21:08 · 1104 阅读 · 1 评论 -
Visible Lattice Points(spoj7001+初探莫比乌斯)gcd(a,b,c)=1 经典
VLATTICE - Visible Lattice Pointsno tags Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0原创 2015-08-17 22:00:16 · 1188 阅读 · 0 评论 -
CO-PRIME(初探 莫比乌斯)NYOJ1066(经典)gcd(a,b)=1
CO-PRIME时间限制:1000 ms | 内存限制:65535 KB难度:3描述This problem is so easy! Can you solve it?You are given a sequence which contains n integers a1,a2……an, your task is to find how many pa原创 2015-08-17 16:11:43 · 1564 阅读 · 0 评论 -
Palindrome Numbers(LA2889)第n个回文数是?
J - Palindrome NumbersTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 2889 WA了一版面,我也是醉了,就因为一个编译环境不同。。。。。。 说多了都是泪。 题原创 2015-06-10 13:52:01 · 1268 阅读 · 0 评论 -
GukiZ and Binary Operations(矩阵+二进制)
Codeforces Round #307 (Div. 2) ,D. GukiZ and Binary Operations,原创 2015-06-16 20:22:03 · 1273 阅读 · 0 评论 -
Add Again(重复元素排序)
Add AgainInput: Standard InputOutput: Standard Output Summation of sequence of integers is always a common problem in Computer Science. Rather than computing blindly, some intelligent techniqu原创 2015-06-09 22:00:53 · 971 阅读 · 0 评论 -
Again Prime? No Time.(uva10870+数论)
Again Prime? No time.Input: standard inputOutput: standard outputTime Limit: 1 secondThe problem statement is very easy. Given a number n you have to determine the largest power of m, not ne原创 2015-05-14 18:41:32 · 975 阅读 · 0 评论 -
Integer Game(UVA11489)3的倍数
K - Integer GameTime Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVA 11489 题意:在n中取数字,使剩下的数是3的倍数,不能取则失败。思路:如果能使当前数为3的倍数,数字和必是3的倍数。原创 2015-06-10 21:06:25 · 1065 阅读 · 0 评论 -
Contemplation! Algebra(矩阵快速幂,uva10655)
Problem EContemplation! AlgebraInput: Standard InputOutput: Standard OutputTime Limit: 1 Second Given the value of a+b and ab you will have to find the value of an+bn InputThe input file原创 2015-03-23 11:32:47 · 594 阅读 · 0 评论 -
Another kind of Fibonacci(矩阵)
Another kind of FibonacciTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1919 Accepted Submission(s): 738Problem DescriptionAs we all k原创 2015-03-23 11:32:41 · 763 阅读 · 0 评论 -
M斐波那契数列(矩阵快速幂+费马小定理)
M斐波那契数列Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1672 Accepted Submission(s): 482Problem DescriptionM斐波那契数列F[n]是一种整数数列,它的定义如下:F[0原创 2015-03-23 11:32:36 · 1275 阅读 · 0 评论 -
POJ1006: 中国剩余定理的完美演绎
POJ1006: 中国剩余定理的完美演绎问题描述 人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天。一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好。通常这三个周期的峰值不会是同一天。现在给出三个日期,分别对应于体力,情感,智力出现峰值的日期。然后再给出一个起始日期,要求从这一天开始,算出最少再过多少天后三个峰值同时出转载 2015-03-22 21:58:25 · 665 阅读 · 0 评论 -
矩阵快速幂取模
参考博客1:据说,矩阵快速幂在递推式优化上相当神奇,而且效率很高。。。 两矩阵相乘,朴素算法的复杂度是O(N^3)。如果求一次矩阵的M次幂,按朴素的写法就是O(N^3*M)。既然是求幂,不免想到快速幂取模的算法,这里有快速幂取模的介绍,a^b %m 的复杂度可以降到O(logb)。如果矩阵相乘是不是也可以实现O(N^3 * logM)的时间复杂度呢?答案是肯定的。转载 2015-02-08 15:52:43 · 1163 阅读 · 0 评论 -
线性递推关系与矩阵乘法
对于一般的具有常系数线性递推关系的递推数列,若需要很快算出某一项的精确值,一般的方法是求出特征方程的解然后解出这个递推关系的通项公式。可是随着递推关系阶数的升高,解特征方程的难度也逐渐增大,甚至在递推关系阶数大于 5 之后,特征方程的次数随之超过 5,根本没有代数解法。本文利用矩阵乘法,提出了一个在 O(k^3 ⌈logn⌈) 的时间复杂度内算出 k 阶常系数线性递推数列第 n 项的精确值的算法,并利用转移矩阵和特征方程的联系,把这个算法的时间复杂度优化到了 O(k^2 ⌈logn⌉).原创 2015-02-08 15:37:15 · 3532 阅读 · 0 评论 -
hdu 1568 (log取对数 / Fib数通项公式)
hdu 1568 (log取对数 / Fib数通项公式)2007年到来了。经过2006年一年的修炼,数学神童zouyu终于把0到100000000的Fibonacci数列(f[0]=0,f[1]=1;f[i] = f[i-1]+f[i-2](i>=2))的值全部给背了下来。接下来,CodeStar决定要考考他,于是每问他一个数字,他就要把答案说出来,不过有的数字太长了。所以转载 2014-03-09 17:44:50 · 1183 阅读 · 0 评论 -
UVA12493 - Stars(求1-N与N互质的个数)欧拉函数
UVA12493 - Stars(求1-N与N互质的个数)欧拉函数 bnuoj26358原创 2015-08-17 12:55:16 · 2440 阅读 · 0 评论 -
Interesting Integers(CF---BAPC 14 + hnoj11589)扩展欧几里得
I Interesting Integerssource: xkcd.com/587Undoubtedly you know of the Fibonacci numbers. Starting withF1 = 1 and F2 = 1, every next number is the sum of the twoprevious ones. This results in the sequence 1, 1, 2, 3, 5, 8, 13, . . ..Now let us consider原创 2015-08-12 22:16:34 · 1509 阅读 · 0 评论 -
Root(hdu5777+扩展欧几里得+原根)
Root-------------------2015 Multi-University Training Contest 7Problem DescriptionGiven a number sum(1≤sum≤100000000),we have m queries which contains a pair (xi,yi) and would like to know the smallest nonnegative integer ki satisfying xkii=yi mod p whe原创 2015-08-12 00:20:17 · 1601 阅读 · 0 评论 -
点到圆弧的距离(csu1503)
1503: 点到圆弧的距离Time Limit: 1 Sec Memory Limit: 128 MB Special JudgeSubmit: 325 Solved: 70[Submit][Status][Web Board]Description输入一个点P和一条圆弧(圆周的一部分),你的任务是计算P到圆弧的最短距离。换句话说,你需要在圆弧上找一个点,到P原创 2015-07-30 22:16:47 · 1619 阅读 · 1 评论