
模板
JW12138
既然出生在这个世上,我就没想着活着回去!!!
展开
-
快速幂( O(log n) )
快速幂模板,时间复杂度O(log n); #include #include using namespace std; int pow_mod(int a,int n,int m)//快速幂,a为底数,n为幂数,m为mod数; { if(n==0) return 1; int x=pow_mod(a,n/2,m); long long ans=(long lo原创 2017-05-23 20:52:40 · 378 阅读 · 0 评论 -
ACM-Java中大数的应用
BigInteger: BigInteger a,b,c; //定义; a=BigInteger.ZERO; //0; b=BigInteger.ONE; //1; c=BigInteger.TEN; //10; c=BigInteger.valueOf(10); //把long long赋给c; a=a.abs(); //绝对值; 要有等号; a=a.add(b);原创 2017-05-24 10:22:40 · 392 阅读 · 0 评论 -
Exponentiation(POJ-1001) Java大数例题
Description Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many comp原创 2017-05-24 10:30:32 · 524 阅读 · 0 评论 -
KMP算法模板
KMP算法是一种改进的字符串匹配算法,又称“看毛片”算法,时间复杂度为O(m+n); 还不是很懂,但是代码挺简单的,先敲个模板,之后再细看; #include #include #include #include #define maxn 10010 using namespace std; int next[maxn]; void getNext(string s) //原创 2017-06-14 11:22:14 · 235 阅读 · 0 评论