摘要: 链接: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) 编辑