2012年8月24日

nyoj 求余数

摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=205View Code 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 long long t; 6 int len; 7 char str[1000010]; 8 scanf("%lld",&t); 9 while(t--)10 {11 long long yushu=0;12 scanf("%s",str);13 len... 阅读全文

posted @ 2012-08-24 21:32 仁者无敌8勇者无惧 阅读(105) 评论(0) 推荐(0) 编辑

nyoj 我排第几个

摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=139View Code 1 #include<stdio.h> 2 #include<string.h> 3 int jiecheng(int x) 4 { 5 int jie=1; 6 for(int i=2;i<=x;i++) 7 jie*=i; 8 return jie; 9 }10 int main()11 {12 int t;13 int len;14 char ch;15 char str[13];16 sca... 阅读全文

posted @ 2012-08-24 21:19 仁者无敌8勇者无惧 阅读(91) 评论(0) 推荐(0) 编辑

nyoj 次方求模

摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=102View Code 1 #include<stdio.h> 2 int main() 3 { 4 long long a,b,n; 5 int t; 6 scanf("%d",&t); 7 while(t--) 8 { 9 long long t=1;10 scanf("%lld%lld%lld",&a,&b,&n);11 for(;b;b>>=1,a=a*a%n)12 {13 ... 阅读全文

posted @ 2012-08-24 20:03 仁者无敌8勇者无惧 阅读(104) 评论(0) 推荐(0) 编辑

快速幂取模

摘要: http://www.reait.com/1/post/2012/03/quickly-take-mode.html 阅读全文

posted @ 2012-08-24 19:34 仁者无敌8勇者无惧 阅读(112) 评论(0) 推荐(0) 编辑

nyoj 快速查找素数

摘要: View Code 1 #include<stdio.h> 2 #include<string.h> 3 int prime[2000010]; 4 void puan_prime() 5 { 6 7 for(int i=2;i<=2000010;i++) 8 { 9 if(!prime[i])10 {11 for(int j=i+i;j<=2000010;j+=i)12 prime[j]=1;13 }14 }15 }16 int main()17 {18 ... 阅读全文

posted @ 2012-08-24 18:12 仁者无敌8勇者无惧 阅读(163) 评论(0) 推荐(0) 编辑

nyoj 光棍节的快乐

摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=451View Code 1 #include<stdio.h> 2 long long a[22],b[22]; 3 void cuo_pai() 4 { 5 a[1]=0; 6 a[2]=1; 7 for(int i=3;i<=22;i++) 8 a[i]=(i-1)*(a[i-1]+a[i-2]); 9 }10 int main()11 {12 long long aa,b;13 cuo_pai();14 while(~scanf(... 阅读全文

posted @ 2012-08-24 17:21 仁者无敌8勇者无惧 阅读(123) 评论(0) 推荐(0) 编辑

nyoj 最大素因子

摘要: View Code 1 #include<stdio.h> 2 #include<string.h> 3 int a[1000010]; 4 void prime() 5 { 6 7 int num=0; 8 for(int i=2;i<=1000010;i++) 9 {10 if(!a[i])11 {12 num++;13 for(int j=1;j*i<=1000010;j++)14 a[... 阅读全文

posted @ 2012-08-24 16:23 仁者无敌8勇者无惧 阅读(111) 评论(0) 推荐(0) 编辑

nyoj 数的长度

摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=69View Code 1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int t; 6 int n; 7 double sum; 8 scanf("%d",&t); 9 while(t--)10 {11 sum=0;12 scanf("%d",&n);13 for(int i=n;i>=1;i--)14 sum+=l... 阅读全文

posted @ 2012-08-24 14:27 仁者无敌8勇者无惧 阅读(113) 评论(0) 推荐(0) 编辑

导航