摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long LL; 6 // 求x和y使得ax+by=d并且|x|+|y|最小。其中d=gcd(a,b) 7 void exgcd(LL a,LL b,LL& d,LL& x,LL& y){ 8 if(!b) d = a,x =... 阅读全文
posted @ 2016-08-25 17:39 Yan_Bin 阅读(150) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long LL; 6 // 求x和y使得ax+by=d并且|x|+|y|最小。其中d=gcd(a,b) 7 void exgcd(LL a,LL b,LL& d,LL& x,LL& y){ 8 if(!b) d = a,x =... 阅读全文
posted @ 2016-08-25 17:18 Yan_Bin 阅读(662) 评论(0) 推荐(0)
摘要: GCD Extreme (II) Given the value of N, you will have to find the value of G. The definition of G is given below: uva 11426 - GCD - Extreme (II)" v:sha 阅读全文
posted @ 2016-08-25 15:21 Yan_Bin 阅读(279) 评论(0) 推荐(0)
摘要: 题意: 判断一个关于n的多项式P(n)能否恒被一个正整数D整除。 输入样例: (n^2-n)/2 (2n^3+3n^2+n)/6 (-n^14-11n+1)/3 输出格式: 如果满足条件就输出“Always an integer”否则输出“Not always an integer”。 分析: 多项 阅读全文
posted @ 2016-08-25 14:38 Yan_Bin 阅读(195) 评论(0) 推荐(0)
摘要: Investigating Div-Sum Property Aninteger is divisible by 3 if the sum of its digits is also divisible by 3. Forexample, 3702 is divisible by 3 and 12( 阅读全文
posted @ 2016-08-25 11:25 Yan_Bin 阅读(191) 评论(0) 推荐(0)
摘要: 也可以由欧拉定理,对任意a属于Zn,a^(phi(n))=1(modn)。于是a的逆就是a^(phi(n) - 1)。 如果n是素数的话,a的逆就是pow_mod(a,n-2,n) 阅读全文
posted @ 2016-08-25 00:53 Yan_Bin 阅读(156) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 // 计算欧拉phi函数。phi(n)是不超过n且与n互素的正整数个数 5 int euler_phi(int n){ 6 int m = (int)sqrt(n + 0.5); 7 int ans = n; 8 // phi(n)=n(1-1/p1)(1-1/p2)...(1-1... 阅读全文
posted @ 2016-08-25 00:36 Yan_Bin 阅读(713) 评论(0) 推荐(0)