随笔分类 -  ACM---数论

数论。
摘要:GCDTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 812Accepted Submission(s): 363Problem DescriptionThe greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,( 阅读全文
posted @ 2013-08-08 09:31 芷水 阅读(298) 评论(0) 推荐(0)
摘要:Calculation 2Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1750Accepted Submission(s): 727Problem DescriptionGiven a positive integer N, your task is to calculate the sum of the positive integers less than N which are not coprime to N. A is said 阅读全文
posted @ 2013-08-07 18:21 芷水 阅读(280) 评论(0) 推荐(0)
摘要:The Euler functionTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2986Accepted Submission(s): 1221Problem DescriptionThe Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smalle 阅读全文
posted @ 2013-08-07 17:11 芷水 阅读(160) 评论(0) 推荐(0)
摘要:欧拉函数:一个整数n,小于且和n互质的正整数的个数(包含1)的个数,用φ(n)表示。完全余数集合:欧拉函数中与n互质的数字的集合.~~~~~~~~~~~~~~性质:如果n是素数,则 φ(n)=n-1;求一个数n的所有互素和 sum=φ(n)*n/2; <==这个性质,很有用。欧拉定理:对于互质的正整数a和n,有aφ(n)≡1modn。费马定理:若正整数a与素数p互质,则有ap-1≡1modp。证明这个定理非常简单,由于φ(p)=p-1,代入欧拉定理即可证明。~~~~~~~~~~~~~~~~~~~~~~补充欧拉公式:1.pk的欧拉函数对于给定的一个素数p,φ(p)=p-1。则对于正整数n= 阅读全文
posted @ 2013-08-07 10:57 芷水 阅读(447) 评论(0) 推荐(0)
摘要:素数打表,总结了两种形式。一种是传统的在一个数组里进行标记,进行判断。一种是直接将素数放进一个数组里。 1 #include 2 #include 3 #include 4 5 6 int prime[1000003],size=0; 7 int s[1000003]; 8 9 void make_ini() //素数打表。直接装在一个数组里面10 {11 int i,j;12 memset(s,0,sizeof(s));13 for(i=2;i<=1000000;i++)14 {15 if(s[i]==0)16 {17 ... 阅读全文
posted @ 2013-08-07 10:22 芷水 阅读(222) 评论(0) 推荐(0)