上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
摘要: 链接http://acm.hdu.edu.cn/showproblem.php?pid=4324View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <algorithm> 5 using namespace std; 6 char map[2500][2500]; 7 int in[2500]; 8 int main( ) 9 {10 int T;11 scanf("%d", &T );12 for( 阅读全文
posted @ 2012-08-02 09:41 淡墨æ末央 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 链接http://acm.hdu.edu.cn/showproblem.php?pid=3342题意 :拓扑排序判断是否成环。View Code 1 #include <stdio.h> 2 #include <string.h> 3 int map[501][501], v[501], in[501], M, N; 4 void Init( ) 5 { 6 memset( map, 0, sizeof map ); 7 memset( in, 0, sizeof in ); 8 memset( v, 0, sizeof v ); 9 int a, b;10 ... 阅读全文
posted @ 2012-08-01 12:03 淡墨æ末央 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1285拓扑排序是对有向无环图的一种排序。表示了顶点按边的方向出现的先后顺序。如果有环,则无法表示两个顶点的先后顺序。拓扑排序方法如下: (1)从有向图中选择一个没有前驱(即入度为0)的顶点并且输出它. (2)从网中删去该顶点,并且删去从该顶点发出的全部有向边. (3)重复上述两步,直到剩余的网中不再存在没有前趋的顶点为止.View Code 1 #include <stdio.h> 2 #include <string.h> 3 int map[501][501], v[501] 阅读全文
posted @ 2012-08-01 11:29 淡墨æ末央 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=2065题意:给你一个素数P(P<=30000)和一串长为n的字符串str[]。字母'*'代表0,字母a-z分别代表1-26,这n个字符所代表的数字分别代表f(1)、f(2)....f(n)。定义: f (k) = ∑(0<=i<=n-1) a^iki (mod p) (1<=k<=n,0<=ai<P)求a0、a1.....an-1View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include 阅读全文
posted @ 2012-07-28 21:27 淡墨æ末央 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=1222View Code 1 #include <stdio.h> 2 #include <string.h> 3 int d[35][35], x[35], map[7][7]; 4 const int N=30; 5 void Gauss( ) 6 { 7 int i=1, j, p, k, t; 8 for( j=1; j<=N; ++ j ){ 9 for( p=i;p<=N; ++ p ){10 if(d[p][j])break ;11 }1... 阅读全文
posted @ 2012-07-28 16:22 淡墨æ末央 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 链接http://poj.org/problem?id=1681View Code 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 #include <cmath> 5 using namespace std; 6 int d[230][230], N, M; 7 char s[16][16]; 8 void solve( int n) 9 {10 int x[230],m[20], t, ans=1000, temp;11 t=M-n;12 for( int 阅读全文
posted @ 2012-07-28 10:43 淡墨æ末央 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 链接http://poj.org/problem?id=1753View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <algorithm> 5 using namespace std; 6 const int N=16; 7 int d[20][20]; 8 int slove( int n ) //枚举自由解 求最小值 9 { 10 int x[20], temp, ans=100, m[4], t, p, k; 11 for 阅读全文
posted @ 2012-07-28 10:42 淡墨æ末央 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=1830构造线性方程组A*X=B;高斯消元解线性方程组。系数矩阵为D[x][y]的含义为第y个开关能够影响第x盏灯。B[i]表示第i盏灯是否需要变化是则为1,否则为0.View Code 1 #include <stdio.h> 2 #include <string.h> 3 int N, begin[50], end[50], d[50][50]; 4 void Gauss( ) 5 { 6 int i, j, k, p, t; 7 for( i=1, j=1; i<=N, j<=N; i++, j 阅读全文
posted @ 2012-07-28 10:09 淡墨æ末央 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 链接 :http://poj.org/problem?id=1061青蛙的约会 http://poj.org/problem?id=2115C Looooops首先我们先讨论欧几里得算法 ( gcd ):gcd( a, b )即求两个数的最大公约数递归算法:int gcd( int a, int b ){ return b==0?a:gcd( b, a%b ); //gcd(a,b) = gcd(a%b,b),这个递归一次以后就终止了无法保证a b可以继续减小,所以把 b 和 a%b交换顺序。}非递归算法:int gcd( int a, int b ){ if( b==0 )ret... 阅读全文
posted @ 2012-07-22 19:43 淡墨æ末央 阅读(638) 评论(0) 推荐(1) 编辑
摘要: 链接:http://poj.org/problem?id=1006本题的主要知识点为: 中国剩余定理中国剩余定理是指若有一些两两互素的整数,则对任意的整数:,以下联立同余方程组对模有公解, 即:经典例题就是韩信点兵了,韩信带2300左右名兵士打仗,战死四五百人,站3人一排,多出2人;站5人一排,多出3人;站7人一排,多出6人。韩信马上说出人数。把问题简化为:已知n%3=2, n%5=3, n%7=2, 求n。因为n%3=2, n%5=3, n%7=2 且 3,5,7互质(互质可以直接得到这三个数的最小公倍数)令x= n%3=2 , y= n%5=3 ,z= n%7=2 使5×7 阅读全文
posted @ 2012-07-21 18:58 淡墨æ末央 阅读(199) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页