
---------数论---------
文章平均质量分 67
tch_1997
这个作者很懒,什么都没留下…
展开
-
HDU1087Super Jumping! Jumping! Jumping!
http://acm.hdu.edu.cn/showproblem.php?pid=1087Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy原创 2017-01-23 23:50:09 · 202 阅读 · 0 评论 -
全排列的编码与解码——【康托展开及其逆运算】
参考过程:点击打开链接参考代码:点击打开链接康托展开表示的是当前排列在n个不同元素的全排列中的名次。比如213在这3个数所有排列中排第3。 那么,对于n个数的排列,康托展开为: 其中表示第i个元素在未出现的元素中排列第几。举个简单的例子: 对于排列4213来说,4在4213中排第3,注意从0开始,2在213中排第1,1在13中转载 2017-04-04 19:55:45 · 639 阅读 · 0 评论 -
全排列next_permutation()的用法
1.std::next_permutation函数原型template class BidirectionalIterator> bool next_permutation (BidirectionalIterator first, BidirectionalIterator last ); template class BidirectionalIterator, class原创 2017-04-04 10:07:50 · 1224 阅读 · 0 评论 -
【快速幂】
二分算a的n次方:int pow(int a,int n){ int ans=1; while(n) { if(n&1) ans*=a; a*=a; n>>=1; } return ans;}快速幂:b and 1 //也就是取b的二进制最低原创 2017-02-26 21:16:45 · 266 阅读 · 0 评论 -
HDU3037Saving Beans 【组合数取模,即,LUCAS定理模板】
http://acm.hdu.edu.cn/showproblem.php?pid=3037Problem DescriptionAlthough winter is far away, squirrels have to work day and night to save beans. They need plenty of food to get th原创 2017-01-23 20:53:58 · 346 阅读 · 0 评论 -
POJ1006生理周期----【模板】CRT中国剩余定理即孙子定理即求解一次同余方程
Chinese remainder theorem(CRT):中国剩余定理是求解一次线性同余方程组的方法。中国剩余定理: 假设整数m1,m2, … ,mn两两互素,则同余方程组 有整数解。 设 是m1,m2,m3…mn的乘积,并设 是除了mi以外的n-1个整数的乘积。 设是Mi模mi的逆元(数论中的倒数)。那么在模M下的解是唯一的。原创 2017-04-02 22:25:48 · 978 阅读 · 0 评论 -
POJ 1061青蛙的约会【扩展欧几里德算法】
http://poj.org/problem?id=1061 A - 青蛙的约会 POJ - 1061 #include#includeusing namespace std;long long x,y,q;long long X,Y,M,N,L;void exgcd(long long a,long long b){ if(b==0)原创 2017-01-23 20:16:25 · 382 阅读 · 0 评论 -
HDU4767(待做)&&HDU2512 【Bell数】
Striling数Bell数复习:http://blog.youkuaiyun.com/acdreamers/article/details/12309269http://blog.youkuaiyun.com/creat2012/article/details/40619031(模板)Bell(hdu4767+矩阵+中国剩余定理+bell数+欧几里德)原创 2017-04-02 19:07:19 · 277 阅读 · 0 评论 -
HDU1018求大数N!的位数【取对数】
Problem DescriptionIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are原创 2017-03-31 21:23:25 · 677 阅读 · 0 评论 -
HDU1576A/B【扩展欧几里德算法模板】
思路:设(A/B)%9973 = K, 则A/B = k + 9973x (x未知), 因此A = kB + 9973xB,又A%9973 = n, 所以kB%9973 = n, 故kB = n + 9973y (y未知)故(k/n)B +(-y/n)*9973 = gcd(B,9973) = 1扩展欧几里得 求出k/n, 再乘以个n,记得取模,就是answer了原创 2017-03-19 17:08:22 · 320 阅读 · 0 评论 -
求最大公约数的线性组合【欧几里得模板及扩展欧几里得模板】
求最大公约数的线性组合(扩展欧几里得定理):#include #include #include #include #include #include #include using namespace std;int x,y;int gcd(int a,int b){ //欧几里得算法求最大公约数 if(b==0)原创 2017-04-02 21:09:05 · 1267 阅读 · 0 评论 -
POJ2407 Relatives 【欧拉函数模板】
https://vjudge.net/problem/POJ-2407RelativesTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14310 Accepted: 7151DescriptionGiven n, a positi原创 2017-03-19 15:52:44 · 330 阅读 · 0 评论 -
HDU2095find your present (2)
http://acm.hdu.edu.cn/showproblem.php?pid=2095Problem DescriptionIn the new year party, everybody will get a "special present".Now it's your turn to get your special present, a lot of pr原创 2017-01-23 23:27:13 · 203 阅读 · 0 评论 -
求n!中某个因子个数【模板】
Problem B: Zhazhahe究竟有多二DescriptionZhazhahe竟然能二到把耳机扔到洗衣机里去洗,真的是二到了一种程度,现在我们需要判断一下zhazhahe二的程度(就是计算zhazhahe的脑残值有几个2的因子),下面给你一个n,n!表示zhazhahe的脑残值。Input输入一个正整数t(0表示样例组数,每组样例输入一个正整原创 2017-01-23 23:33:12 · 536 阅读 · 0 评论 -
HDU1061Rightmost Digit
http://acm.hdu.edu.cn/showproblem.php?pid=1061Problem DescriptionGiven a positive integer N, you should output the most right digit of N^N. InputThe input contains severa原创 2017-01-23 23:44:15 · 282 阅读 · 0 评论 -
POJ2773 Happy
http://poj.org/problem?id=2773DescriptionTwo positive integers are said to be relatively prime to each other if the Great Common Divisor (GCD) is 1. For instance, 1, 3, 5, 7, 9...are all原创 2017-01-23 23:45:33 · 228 阅读 · 0 评论 -
POJ1284 Primitive Roots
http://poj.org/problem?id=1284DescriptionWe say that integer x, 0 i mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive powers of 3 modulo 7 are 3, 2, 6, 4原创 2017-01-23 23:47:18 · 256 阅读 · 0 评论 -
素数判定与大数分解【Miller-rabin算法】【pollard-rho算法】
对应练习题:SDNUOJ1 1286点击打开链接1.Miller-rabin算法:Miller-rabin算法是一个用来快速判断一个正整数是否为素数的算法。根据费马小定理,如果p是素数,则a^(p-1)≡1(mod p)对所有的a∈[1,n-1]成立。所以如果在[1,n-1]中随机取出一个a,发现不满足费马小定理,则证明n必为合数。【但是每次转载 2017-04-04 17:23:00 · 2271 阅读 · 0 评论