上一页 1 2 3 4 5 6 7 8 ··· 16 下一页
摘要: http://poj.org/problem?id=2992数学,质数,快速求n!中质数p的个数 1 #include <stdio.h> 2 #include <string.h> 3 4 int valid[441] = {0}; 5 int ans[100], tot = 0; 6 7 //O(N)筛质数表 8 void get_prime(int n) 9 {10 int i, j;11 for(i=2; i<=n; i++)12 {13 if(valid[i] == 0)14 {15 tot ++;1... 阅读全文
posted @ 2013-05-27 15:10 Yuan1991 阅读(154) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2965搜索没用搜索,按一个大神的算法做的 1 #include <stdio.h> 2 #include <string.h> 3 4 int main() 5 { 6 int i, j, k, a[4][4], sum = 0; 7 char c; 8 memset(a, 0, sizeof(a)); 9 for(i=0; i<4; i++)10 {11 for(j=0; j<4; j++)12 {13 scanf("%c", &c);14 ... 阅读全文
posted @ 2013-05-26 17:12 Yuan1991 阅读(100) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3660图论,最短路,floyd 1 #include <stdio.h> 2 #define N 123 3 4 const int inf = 1<<29; 5 int n, g[N][N]; 6 7 int min(int x, int y) 8 { 9 return x<y? x: y;10 }11 12 void floyd()13 {14 for(int k=1; k<=n; k++)15 {16 for(int i=1; i<=n; i++)17 {18 ... 阅读全文
posted @ 2013-05-26 11:47 Yuan1991 阅读(109) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3615图论,最短路,DP,floyd 1 #include <stdio.h> 2 #define N 321 3 4 const int inf = 1<<29; 5 int n, g[N][N]; 6 7 int min(int x, int y) 8 { 9 return x<y? x: y;10 }11 12 int max(int x, int y)13 {14 return x>y? x: y;15 }16 17 void floyd()18 {19 for(int k=1; k<=n; 阅读全文
posted @ 2013-05-26 11:25 Yuan1991 阅读(98) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3090数论,欧拉函数,递推求欧拉函数 1 #include <stdio.h> 2 3 const int maxn = 1010; 4 5 int minDiv[maxn], phi[maxn], sum[maxn]; 6 7 void genPhi() 8 { 9 for(int i=1; i<maxn; i++)10 {11 minDiv[i] = i;12 }13 for(int i=2; i*i<maxn; i++)14 {15 if(minDiv[i]... 阅读全文
posted @ 2013-05-25 21:15 Yuan1991 阅读(169) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 ··· 16 下一页