上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页

2012年8月24日

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) 编辑

2012年8月20日

强连通分量——Tarjan算法

摘要: http://www.byvoid.com/blog/scc-tarjan/强连通分量是有向图中的概念,我们先说强连通分量的定义吧:在一个图的子图中,任意两个点相互可达,也就是存在互通的路径,那么这个子图就是强连通分量(或者称为强连通分支)。如果一个有向图的任意两个点相互可达,那么这个图就称为强连通图。 我们常用的求强连通分量的算法有两个,一个是Kosaraju算法,这个算法是基于两次dfs来实现的;还有一个就是Tarjan算法,这个算法完成一次dfs就可以找到图中的强连通分支。我的这篇文章主要介绍Tarjan算法。 Tarjan算法是基于这样一个原理:如果u是某个强连通分量的根,那... 阅读全文

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

2012年8月19日

素数打表

摘要: void init_prim() { memset(visit, true, sizeof(visit)); int num = 0; for (int i = 2; i <= n; ++i) { if (visit[i] == true) { num++; prime[num] = i; } for (int j = 1; ((j <= num) && (i * prime[j] <= n)); ++j) {... 阅读全文

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

拓扑排序

摘要: http://tobyaa.blog.163.com/blog/static/30248591201261810257856/ 阅读全文

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

上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页

导航