08 2013 档案
摘要:http://poj.org/problem?id=1416题意:将一个数分成几部分,使其分割的各个数的和最大并且小于所给的数。凌乱了。。参考的会神的代码。。orz... 1 #include 2 #include 3 4 int arr[102],ans[102]; 5 int max,len,f; 6 int a,b; 7 8 void dfs(int n,int now,int sum,int k,int t) 9 {10 int m = n % 10;11 if (!n)12 {13 arr[k] = now;14 if ...
阅读全文
摘要:http://poj.org/problem?id=2676填九宫格思路:将每一行,每一列及每一个3*3块中出现的数字标记上,将可填的空的位置记录下来,枚举1-9,填入合适的数。 1 #include 2 #include 3 int row[10][10],col[10][10],arr[10][10];//row[x][i]表示i所在的行为x; 4 //col[y][i]表示i所在的列为y; 5 //arr[n][i]表示i所在...
阅读全文
摘要:http://poj.org/problem?id=2531不太理解这个代码。。。 1 #include 2 #include 3 int map[32][32],v[32]; 4 int n,max; 5 void dfs(int row,int sum) 6 { 7 8 int ans = sum; 9 v[row] = 1;10 for (int i = 1; i max)18 max = ans;19 for (int i = row+1; i sum)22 {23 dfs(i,ans);...
阅读全文
摘要:http://poj.org/problem?id=1321思路:按行搜索,回溯时还原棋盘。 1 #include 2 #include 3 int map[9][9],vis[9]; 4 int ans,n,k; 5 void dfs(int row,int cnt) 6 { 7 8 if (k==cnt) 9 {10 ans++;11 return ;12 }13 if (row > n)14 return ;15 for (int i = 1; i <= n; i ++)16 {17 ...
阅读全文
摘要:http://poj.org/problem?id=3009题意:一个小球要从2走到3,1代表障碍物,0代表可走。要求如果小球没遇到障碍物1,则小球按原来的方向一直走,直到遇到障碍物,障碍物变成0,小球任选一个方向继续走,此时步数加1,问从2走到3最少需要几步。 1 #include 2 #include 3 int map[32][32]; 4 int s_x,s_y,e_x,e_y,min; 5 int dir[4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; 6 void dfs(int x,int y,int step,int d) 7 { 8 if...
阅读全文
摘要:http://poj.org/problem?id=2488题意:给定一个row*col 的棋盘,列上用字母A,B,C······ 表示,行上用数字1,2,3······表示,问马是否能走遍整个棋盘,并将走的路径按字典序顺序输出。思路:只要按照dir[8][2] = {{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};这个方向搜索,得出的路径即按字典序输出的。 1 #include 2 #include 3 ch
阅读全文
摘要:http://poj.org/problem?id=3414题意:给出1号杯子的容量a,2号杯子的容量b,目标盛水量c。问两个杯子经过怎样的变换能盛出c容量的水,输出最小步数及转换过程,如不能转换,输出“‘impossible”。思路:总共有6种转换,bfs搜索每一种转换,并记录前一个状态。最后将记录的状态倒着输出。 1 #include 2 #include 3 #include 4 #include 5 #include 6 const int N=112; 7 using namespace std; 8 string oper[7] = {"","FILL
阅读全文
摘要:http://poj.org/problem?id=3126题意:给两个四位数n,m,将n变成m需要多少步,要求每次只能改变n的某一位数,即改变后的数与改变前的数只有一位不同,且每次改变后的数都是素数。思路:bfs+枚举每一位+素数筛选。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int N=10000; 6 int prime[N],vis[N],b[4]; 7 void is_prime() 8 { 9 memset(prime,0,sizeof(prime));10 for (in...
阅读全文
摘要:http://poj.org/problem?id=2251题意:输出从S->E的最少时间,即最少步数。BFS搜索六个方向。 1 #include 2 #include 3 #include 4 using namespace std; 5 int e_x,e_y,e_z; 6 int n,row,col,vis[32][32][32]; 7 char map[32][32][32]; 8 int dir[6][3] = {{0,0,1},{0,0,-1},{0,-1,0},{0,1,0},{1,0,0},{-1,0,0}}; 9 struct node10 {11 int x;...
阅读全文
摘要:http://poj.org/problem?id=3087题意:每组3个串,前两个串长度为n,第三个串长度为2*n,依次从第二个串(s2)中取一个字符,从第一个串(s1)中取一个字符,......,直至取完,如果组成的新串(s)和第三个字符串相同则输出组数和匹配成功的次数,如果不相同,则将s串的前n个字符作为s1,后n个字符作为s2,接着匹配,如果永远匹配不成s,则输出组数和-1。思路:简单的字符串模拟,关键是判断输出-1的情况,如果一直匹配与 s不同,但与原来的strcat(s1,s2)相同,则证明无法匹配成功,因为此时字符串已经匹配了一个周期。 1 #include 2 #includ.
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1634将一个数表示成素数相乘的形式,其中素数从小到大排列。 1 #include 2 #include 3 #include 4 const int N=65536; 5 int a[N]; 6 void is_prime() 7 { 8 a[1] = 0,a[2] = 1; 9 for (int i = 3; i x)38 break;39 while(a[i])40 ...
阅读全文
摘要:http://poj.org/problem?id=3349题意:给出n组数据,每组数据有六个数,这n组数据中若有两组数据不管是从某个数顺时针读还是逆时针读都相同,输出“Twin snowflakes found.”,否则,输出"No two snowflakes are alike."思路:将每组数据求和对大素数取余,将sum相同的放在同一个邻接表中,然后从邻接表中查找符合条件的数据。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int p=99983; 8 co
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1468简单的素数筛选会超时,因为是多组,所以先打表会更快,这样就不用每次都筛选了。 1 #include 2 #include 3 #include 4 const int N=1000002; 5 long long a[N]; 6 void printf_prime( ) 7 { 8 a[1] = 0; 9 a[2] = 1;10 for (int i = 3; i < N; i ++)11 {12 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2497题意:给定一些点和边的关系,判断S点是否在所构成无向图的所有环里。思路:用并查集将所有(除去S及与 S有关的点)有关系的点放在一个集合里,若此时图中还存在环,那么一定不包含S。 1 #include 2 #include 3 const int maxn = 10002; 4 5 int f[maxn],n; 6 int find(int x) 7 { 8 if (x!=f[x]) 9 f[x] = find(f[x...
阅读全文
摘要:http://poj.org/problem?id=1840题意:给出系数a1,a2,a3,a4,a5,求满足方程的解有多少组。思路:有a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 可得 -(a1x13+ a2x23) = a3x33+ a4x43+ a5x53;先枚举x1,x2,用hash[]记录 sum出现的次数,然后枚举后三个点,若左边出现的sum在右边可以找到,那么hash[sum]即为解的个数。 1 #include 2 #include 3 #include 4 #define N 25000000 5 using namespace std; 6 ...
阅读全文
摘要:http://poj.org/problem?id=2002题意:给出n组坐标,判断这些坐标能组成的正方形的个数。思路:参考某大神的想法,先枚举两个点,然后利用公式表示出另外两个点,判断这两个点是否在这n组坐标中,其中查找另两个坐标用的set容器。已知 (x1,y1)(x2,y2);则:x3 = x1+(y1-y2); y3 = y1 -(x1-x2); x4 = x2 +(y1-y2);y4 = y2 -(x1-x2);或:x3 = x1 -(y1-y2);y3 = y1+(x1-x2); x4 = x2 -(y1-y2);y4 = y2 +(x1-x2); 1 #include 2 ...
阅读全文
摘要:http://poj.org/problem?id=2418题意:给定一系列字符串,要求按字典序升序输出每个串,并输出每个串出现的百分比。用map做的,交c++A了,G++ WA。。so sad。。后来发现是输出格式写错了,现在改过来了。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 int main() 10 { 11 char s[102]; 12 ...
阅读全文
摘要:http://poj.org/problem?id=2230题意:给出n个field及m个连接field的边,然后要求遍历每条边仅且2次,求出一条路径来。 1 #include 2 #include 3 const int maxn = 10010; 4 const int maxm = 2*50005; 5 int head[maxn],vis[maxm]; 6 struct node 7 { 8 int u; 9 int v;10 int next;11 } edge[maxm];12 int n,m,cnt;13 void init()14 {15 m...
阅读全文
摘要:http://poj.org/problem?id=1386题意:给定若干个单词,若前一个的尾字母和后一个单词的首字母相同,则这两个单词可以连接,问是否所有的单词都能连接起来。思路:欧拉路的判断,且为有向图,将每个单词的首尾字母看做节点,中间字母看做边,建图。(1)用并查集判断图是否连通。(2)判断奇数节点的个数为0或2个,其余节点均入度=出度。 1 #include 2 #include 3 const int N=1010; 4 const int M=28; 5 int in[M]; 6 int out[M]; 7 int f[M],vis[M]; 8 void init() 9 {..
阅读全文
摘要:http://poj.org/problem?id=2513题意:给一些木棒,木棒两端图上颜色,将端点颜色相同的木棒连在一起,问是否能连成一条直线。思路:将两端的颜色看成点,将木棒看成边,判断是否构成欧拉路。欧拉路:图G,若存在一条路,经过G中每条边有且仅有一次,称这条路为欧拉路,如果存在一条回路经过G每条边有且仅有一次,称这条回路为欧拉回路。具有欧拉回路的图成为欧拉图。判断欧拉路是否存在的方法有向图:图连通,有一个顶点出度大入度1,有一个顶点入度大出度1,其余都是出度=入度。无向图:图连通,只有两个顶点是奇数度,其余都是偶数度的。判断欧拉回路是否存在的方法有向图:图连通,所有的顶点出度=入度
阅读全文
摘要:http://poj.org/problem?id=2442题意:给你n*m的矩阵,然后每行取一个元素,组成一个包含n个元素的序列,一共有n^m种序列,让你求出序列和最小的前n个序列的序列和。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int N=2002; 8 9 int main()10 {11 int T,m,n,arr1[N],arr2[N];12 priority_queue,less >q;13 scanf("%d",...
阅读全文
摘要:http://poj.org/problem?id=2151看的题解。。表示没看懂状态转移方程。。#include#includeint m,t,n;double dp[1002][32][32],p[1002][32],tt[1002][32];int main(){ int i,j,k; while(~scanf("%d%d%d",&m,&t,&n)) { if (!m && !t && !n) break; memset(dp,0.0,sizeof(dp)); memset(tt,0.0,sizeof(tt...
阅读全文
摘要:http://poj.org/problem?id=2299此题即为归并排序求逆序数。 1 #include 2 #include 3 const int N=500002; 4 int a[N],temp[N]; 5 long long ans; 6 void merge_arr(int first,int mid,int last)//合并区间 7 { 8 int k = 0; 9 int i = first,n = mid;10 int j = mid+1,m = last;11 while(i 2 #include 3 #include 4 us...
阅读全文
摘要:http://poj.org/problem?id=3080寻找最长公共子串。。暴搜的。。 1 #include 2 #include 3 int main() 4 { 5 int t,n; 6 char s[12][62],ss[62],str[62]; 7 scanf("%d",&t); 8 while(t--) 9 {10 scanf("%d%*c",&n);11 int i,j,k;12 for (i = 0; i max_len)32 {33 ...
阅读全文
摘要:http://poj.org/problem?id=1035题意:给定一个单词判断其是否在字典中,若存在输出"%s is correct",否则判断该单词删掉一个字母,或增加一个字母,或替换一个字母后是否存在于字典中。 1 #include 2 #include 3 int deal(char *s1,char *s2) 4 { 5 int i = 0; 6 int len1 = strlen(s1); 7 int len2 = strlen(s2); 8 if(len1==len2)//替换 9 {10 while(i < len1 &...
阅读全文
摘要:求最小点覆盖数,即最大匹配数,匈牙利算法。 1 #include 2 #include 3 int map[505][505],vis[505],linker[505];//linker[]记录V2中的点i在V1中所匹配的点x的编号 4 int n,k; 5 int dfs(int x) 6 { 7 for (int i = 1; i <= n; i++) 8 { 9 if (map[x][i] && !vis[i])//x到i有边且i点未被标记10 {11 vis[i] = 1;12 if (!...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1867 1 #include 2 #include 3 #include 4 const int maxn = 102; 5 const int INF=1 dis[i][k] + dis[k][j])//更新距离34 dis[i][j] = dis[i][k] + dis[k][j];35 }36 }37 }38 }39 int main()40 {41 ...
阅读全文
摘要:计算最大流,EK算法模板题。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=520; 6 const int maxm=100010; 7 const int INF=1q;34 max_flow = 0;35 for (;;)36 {37 memset(a,0,sizeof(a));38 q.push(s);39 a[s] = INF;//源点容量为无穷40 while(!q.empty())41 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2138注意该图为有向图,1000个点应该最多有1000*999条边。在这跪了一下。。。 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 const int maxn=1000002; 8 int head[maxn],vis[maxn]; 9 int n,m,cnt;10 struct node11 {12 int u;13 int v;14 int...
阅读全文
摘要:http://poj.org/problem?id=10941.判断所给关系是否为合法的拓扑序列,若存在环,输出"Inconsistency found after %d relations."但仍继续输入。2.判断是否可以确定序列,若不可以确定,继续输入,若可以确定输出"Sorted sequence determined after %d relations: %s."后,继续输入数据。3.若输入完数据仍不可以确定序列,输出"Sorted sequence cannot be determined.". 1 #include 2
阅读全文
摘要:http://poj.org/problem?id=1459题意:有一个电路网络,每个节点可以产生、传递、消耗若干电量,有点线连接结点,每个电线有最大传输量,求这个网络的最大消费量。思路:从源点到发电站连边,流量为发电量,从用户到汇点连边,流量为消费量,再根据电线连双向边,求最大流即可。 1 #include 2 #include 3 #include 4 const int N=220; 5 const int INF=1q;14 memset(pre,-1,sizeof(pre));15 pre[s] = 0;16 int k;17 q.push(s);18...
阅读全文
摘要:http://poj.org/problem?id=3687看题意看了半天没看懂怎么回事,看完Discuss彻底凌乱了。。后来看了题解才懂,就是逆向建图+拓扑排序,建图时要判重边。 1 #include 2 #include 3 int map[202][202]; 4 int n,in[202],ans[202]; 5 int topo() 6 { 7 int i,j; 8 for (i = n; i >= 1; i --) 9 {10 for (j = n; j >= 1; j --)11 {12 if (!i...
阅读全文
摘要:http://poj.org/problem?id=3083S为起点,E为中点,输出S—>E沿左边走的步数,沿右边走的步数,和最短步数。因为S—>E沿左边走的步数等于E—>S沿右边走的步数,故只需DFS搜索沿右边走的步数,改变起止点即可。然后BFS搜索最少步数。 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 const int N=55; 8 char map[N][N]; 9 int dir[4][2] = {{0,-1},{-1,0},{0,1},{1,0}};//顺时针方向1
阅读全文
摘要:http://poj.org/problem?id=3278 1 #include 2 #include 3 #include 4 #define MAX 1000002 5 using namespace std; 6 int vis[MAX],step[MAX]; 7 int dir[3][2] = {{1,1},{1,-1},{2,0}}; 8 queue q; 9 int n,m;10 void bfs(int s)11 {12 vis[s] = 1;13 q.push(s);14 while(!q.empty())15 {16 s =...
阅读全文
摘要:http://poj.org/problem?id=1062每个物品看成一个节点,酋长的允诺也看作一个物品, 如果一个物品加上金币可以交换另一个物品,则这两个节点之间有边,权值为金币数,求第一个节点到所有节点的最短路。因为有等级限制,所以枚举每个点作为最低等级,选取符合所有符合等级限制的点。注意:酋长的等级不一定是最高的。 1 #include 2 #include 3 const int INF=1 0 && dis[j] > min + price[pos][j])33 {34 dis[j] = price[pos][j]+min;3...
阅读全文
摘要:http://poj.org/problem?id=3259spfa判断负环 1 #include 2 #include 3 #include 4 5 const int oo = 1qu;38 qu.push(s);39 dis[s] = 0;40 num[s] = 1;41 vis[s] = true;42 while(!qu.empty()){43 int u = qu.front();44 qu.pop();45 vis[u] = false;46 for(int i = h...
阅读全文
摘要:http://poj.org/problem?id=1860spfa判断正环 1 #include 2 #include 3 #include 4 using namespace std; 5 const int Max=52050; 6 7 struct node 8 { 9 int u;10 int v;11 double r;12 double c;13 int next;14 } edge[Max];15 int head[Max],cnt,vis[Max],pot[Max];16 int n,m;17 double dis[Max];1...
阅读全文
摘要:http://poj.org/problem?id=2240 1 #include 2 #include 3 const int INF=1 1)70 flag = 1;71 }72 if (flag)73 printf("Case %d: Yes\n",o);74 else75 printf("Case %d: No\n",o);76 }77 return 0;78 }View Code
阅读全文
摘要:http://poj.org/problem?id=1125题意:首先,题目可能有多组测试数据,每个测试数据的第一行为经纪人数量N(当N=0时,输入数据结束),然后接下来N行描述第i(1 2 #include 3 const int INF=1 dis[i][k] + dis[k][j])25 dis[i][j] = dis[i][k] + dis[k][j];26 }27 }28 }29 }30 int main()31 {32 while(~scanf("%d",&n)&&n)33 {...
阅读全文
摘要:http://poj.org/problem?id=1258 1 #include 2 #include 3 const int maxn=110; 4 const int INF = 1 map[pos][j])32 dis[j] = map[pos][j];33 }34 }35 }36 void init()37 {38 sum = 0;39 for (int i = 0; i <= n; i ++)40 {41 for (int j = 0; j <= n; j ++)42 {...
阅读全文
摘要:http://poj.org/problem?id=1789读不懂题再简单也不会做,英语是硬伤到哪都是真理,sad++。此题就是一个最小生成树,两点之间的权值是毎两串之间的不同字母数。 1 #include 2 #include 3 const int N=2020; 4 const int INF=1 map[pos][j])31 dis[j] = map[pos][j];32 }33 34 }35 }36 void init()37 {38 sum = 0;39 for (int i = 0; i <= n; i ++...
阅读全文
摘要:http://poj.org/problem?id=2485此题是求最小生成树里的最大权值。prim算法: 1 #include 2 #include 3 const int maxn=505; 4 const int INF = 1 maxm)28 {29 maxm = min;30 }31 vis[pos] = 1;32 for (int j = 1; j map[pos][j])35 dis[j] = map[pos][j];36 }37 }3...
阅读全文
摘要:http://poj.org/problem?id=2996 1 #include 2 #include 3 char map[55][55]; 4 void find1(char ch) 5 { 6 int flag = 0; 7 for (int i = 15; i >= 1; i -= 2) 8 { 9 if (flag)10 break;11 for (int j = 2; j <= 30; j += 4)12 {13 if (map[i][j]==ch)14 ...
阅读全文
摘要:http://poj.org/problem?id=1068 1 #include 2 #include 3 int main() 4 { 5 int a[101],b[102],v[101]; 6 int t,n; 7 scanf("%d",&t); 8 while(t--) 9 {10 scanf("%d",&n);11 memset(a,0,sizeof(a));12 for (int i = 1; i 0)21 {22 while(k--)2...
阅读全文
摘要:http://poj.org/problem?id=2965 1 #include 2 #include 3 int arr[4][4];//存储状态 4 int main() 5 { 6 int i,j; 7 char ch; 8 memset(arr[0],0,sizeof(arr[0])); 9 for (i = 0; i < 4; i ++)10 {11 for (j = 0; j < 4; j ++)12 {13 ch = getchar();14 if(ch=='...
阅读全文
摘要:http://poj.org/problem?id=1753题意:有一个4*4的方格,每个方格中有一粒棋子,棋子一面为白色,一面为黑色。每次翻转一粒棋子,则它周围的棋子也随之翻转,直至方格全为黑棋或全为白棋,输出最少的翻转次数,如果不可能达到此种状态,输出Impossible。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 struct node 7 { 8 int step;//步数 9 int state;//状态10 };11 int vis[65538];12 int f[16]...
阅读全文
摘要:http://poj.org/problem?id=3006 1 #include 2 #include 3 int is_prime(int n) 4 { 5 int i,m; 6 if (n==1) 7 return 0; 8 m = sqrt(n); 9 for (i = 2; i <= m; i ++)10 {11 if (n%i==0)12 return 0;13 }14 return 1;15 }16 int main()17 {18 int a,d,n,i;19...
阅读全文
摘要:http://poj.org/problem?id=2499 1 #include 2 int main() 3 { 4 int t,a,b; 5 scanf("%d",&t); 6 for (int i = 1; i b)14 {15 l += a/b;16 a = a % b;17 }18 else19 {20 r += b/a;21 b = ...
阅读全文
摘要:http://poj.org/problem?id=1316 1 #include 2 #include 3 int f[10001]; 4 int main() 5 { 6 int i; 7 memset(f,0,sizeof(f)); 8 for (i = 1; i < 10001; i ++) 9 {10 int n = i;11 int ans = n;12 while(n)13 {14 ans += n%10;15 n /= 10;16 ...
阅读全文
摘要:http://poj.org/problem?id=2388 1 #include 2 #include 3 const int N=10010; 4 using namespace std; 5 int main() 6 { 7 int f[N],n,i; 8 scanf("%d",&n); 9 for (i = 1;i <= n;i ++)10 scanf("%d",&f[i]);11 sort(f+1,f+1+n);12 printf("%d\n",f[(n+1)/2]);13 return 0;14 }V
阅读全文
摘要:http://poj.org/problem?id=2105 1 #include 2 #include 3 int main() 4 { 5 char str[101]; 6 int pow[8] = {1,2,4,8,16,32,64,128}; 7 int n,t; 8 scanf("%d",&n); 9 while(n--)10 {11 int ans = 0;12 t = 1;13 scanf("%s",str);14 int len = strlen(str);15 ...
阅读全文
摘要:http://poj.org/problem?id=1552 1 #include 2 const int N=102; 3 int main() 4 { 5 int n,f[N],g[N]; 6 int cnt; 7 while(1) 8 { 9 cnt = 0;10 scanf("%d",&n);11 if (n==-1)12 break;13 f[0] = n;14 g[0] = 2*n;15 int i ;16 for ...
阅读全文
摘要:http://poj.org/problem?id=1207此题注意比较n,m的大小,还有最后的原样输出。 1 #include 2 int main() 3 { 4 int n,m,i,j,max,t; 5 while(~scanf("%d%d",&n,&m)) 6 { 7 int n1 = n; 8 int m1 = m; 9 max = 0;10 if(n > m)11 {12 t = n;13 n = m;14 ...
阅读全文
摘要:http://poj.org/problem?id=1013 1 #include 2 #include 3 #include 4 const int INF=1 max)68 {69 max = fabs(ans[i]);70 pos = i;71 }72 }73 }74 if(ans[pos] <= 0)75 printf("%c is the counterfeit ...
阅读全文
摘要:http://poj.org/problem?id=1008按第一种记录方法算出总天数,然后按第二种记录方式输出。#include#includechar Hab[20][11] = { "","pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", &
阅读全文
摘要:http://poj.org/problem?id=1005#include#include#include const double pi = acos(-1.0);int main(){ int t,j; scanf("%d",&t); for (int i = 1;i = 1.0/2*(pi*r)) break; cnt++; } printf("Property %d: This property will begin eroding in year %d.\n",i, cnt); } ...
阅读全文
摘要:http://poj.org/problem?id=1003题意:最上面的卡片露出它下面卡片的1/2,第二个上面的卡片露出它下面的1/3,......,依次类推。。求能放的卡片数。。。#include#includeint main(){ double len; while(~scanf("%lf",&len)&&len) { double sum = 0; int i; for ( i = 2;; i ++) { sum +=1.0/i; if(sum >= len) ...
阅读全文
摘要:http://poj.org/problem?id=1046纯水题。。找距离最短的输出。。#include#includeconst int INF=1<<28;struct node{ int r; int g; int b;} a[20];int main(){ int i,r1,g1,b1,dis,pos; for (i = 0 ; i < 16; i ++) { scanf("%d%d%d",&a[i].r,&a[i].g,&a[i].b); } while(1) { int min = INF; ...
阅读全文
摘要:http://poj.org/problem?id=2000#includeconst int N=10010;int main(){ int coin[N]; long long n,i = 1,j,k; j = 1; k = 0; while (i = j) { k = 0; j++; } } while(~scanf("%lld",&n)&&n) { long long scoin = 0; for (i = 1; i <= n; i ++...
阅读全文
摘要:http://poj.org/problem?id=1218题意:门的状态有两种开或关,初始化为开,每次进行状态转换,第一次把门号是1的倍数的门状态转换,第二次把门号是2的倍数的门状态转换,......,第n次把状态是n的倍数的门状态转换,输出最后有几个门是开的状态。#include#includeint main(){ int i, t,a[1010],n; scanf("%d",&t); while(t--) { scanf("%d",&n); memset(a,0,sizeof(a)); for (i = 1; i <= ..
阅读全文
摘要:http://poj.org/problem?id=2017 1 #include 2 int main() 3 { 4 int n,mile,hour; 5 while(~scanf("%d",&n)&&n!=-1) 6 { 7 int sum = 0,h = 0; 8 while(n--) 9 {10 scanf("%d%d",&mile,&hour);11 h = hour-h;12 sum += mile*h;13 h ...
阅读全文

浙公网安备 33010602011771号