上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 57 下一页

2011年7月17日

poj 1218 THE DRUNK JAILER

摘要: #include<iostream>using namespace std;int list[101];int main(){ int t,n,i,round,sum; cin>>t;while(t--) { cin>>n; memset(list,0,sizeof(list)); for(round=1;round<=n;round++) for(i=round;i<=n;i+=round) list[i]++; sum=0; for(i=1;i<=n;i++) if(list[i]%2) sum++; cout<<sum&l 阅读全文

posted @ 2011-07-17 23:55 sysu_mjc 阅读(89) 评论(0) 推荐(0) 编辑

poj 1247 Magnificent Meatballs

摘要: #include <iostream>using namespace std;int main(){ int n,list[31],total,i; while(cin>>n&&n) { total=0; for( i=1;i<=n;i++) { cin>>list[i]; total+=list[i]; } if(total%2!=0) cout<<"No equal partitioning.\n"; else { total/=2; int sum=0; for( i=1;;i++) { sum+= 阅读全文

posted @ 2011-07-17 23:55 sysu_mjc 阅读(80) 评论(0) 推荐(0) 编辑

poj 1207 The 3n + 1 problem

摘要: #include <iostream>using namespace std;int cycle(int n){ int t=1; while(n!=1) { if(n%2) n=3*n+1; else n/=2; t++; } return t;}int main(){ int i,j,k,max,m,tag; while(cin>>i>>j) { tag=0; if(i>j) { tag=1; swap(i,j); } max=1; for(k=i;k<=j;k++) { if(cycle(k)>max) m=k,max=cycle(k 阅读全文

posted @ 2011-07-17 23:54 sysu_mjc 阅读(120) 评论(0) 推荐(0) 编辑

poj 1171 Letter Game

摘要: #include <iostream>#include <string>using namespace std;struct node{ char words[10]; int len,val;}dic[40010];int c_fre[26],value[26] = {2,5,4,4,1,6,5,5,1,7,6,3,5,2,3,5,7,2,1,2,4,6,6,7,5,7};char coll[10],lett[10];int to_value(char ch[]){ int s=0; for(int i=0;i<strlen(ch);++i) s+=value[ 阅读全文

posted @ 2011-07-17 23:53 sysu_mjc 阅读(220) 评论(0) 推荐(0) 编辑

poj 1159 Palindrome

摘要: #include <iostream> // DP + 滚动数组#include <string>using namespace std;#define MAXN 5005int ans[2][MAXN];int main(){ int n; char s[MAXN]; scanf("%d%s",&n,s); for (int i=n-1;i>=0;--i) // 注意i是从大到小,因为求解ans[i][j]过程需要先知道ans[i+1][j] { for (int j=i+1;j<n;++j) { ... 阅读全文

posted @ 2011-07-17 23:52 sysu_mjc 阅读(116) 评论(0) 推荐(0) 编辑

poj 1163 The Triangle

摘要: #include<iostream>using namespace std;int n,triangle[101][101],tmp[101][101];int highest(int ii,int jj){ if(ii==n) return triangle[ii][jj]; if(tmp[ii][jj]!=-1) return tmp[ii][jj]; int a,b; a=(triangle[ii][jj]+highest(ii+1,jj)); b=(triangle[ii][jj]+highest(ii+1,jj+1)); tmp[ii][jj]=a>b?a:b; r 阅读全文

posted @ 2011-07-17 23:52 sysu_mjc 阅读(115) 评论(0) 推荐(0) 编辑

poj 1146 ID Codes

摘要: #include<iostream>#include<algorithm>#include<string>using namespace std;int main(){ string line; while(cin>>line&&line!="#") { if(next_permutation(line.begin(),line.end())) cout<<line<<endl; else cout<<"No Successor\n"; }return 0 阅读全文

posted @ 2011-07-17 23:51 sysu_mjc 阅读(97) 评论(0) 推荐(0) 编辑

poj 1141 Brackets Sequence

摘要: #include<iostream>#include <string>#define max 9999using namespace std;char s[110];int ans[110][110],pipei[110][110];void output(int x,int y){ if(x>y) return ; else if(x==y) { if(s[x]=='('||s[x]==')') printf("()"); else printf("[]"); } else { if(pip 阅读全文

posted @ 2011-07-17 23:50 sysu_mjc 阅读(155) 评论(0) 推荐(0) 编辑

poj 1125 Stockbroker Grapevine

摘要: // 题意: 给定n个人,求出从谁开始传递消息,使得所有人都知道这个消息所花费的时间最短,// 最短时间是多少?如果网络不通,就输出disjoint// 思路: 实际上是求最短路,先用floyd算法求出两两最短路,// 再求出从每个点开始的最长路,最后这n个最长路中的最小值即是答案#include <iostream> //floyd算法,每对顶点之间的最短路径using namespace std; #define inf 100000 #define maxn 102int distF[maxn][maxn]... 阅读全文

posted @ 2011-07-17 23:48 sysu_mjc 阅读(175) 评论(0) 推荐(0) 编辑

poj 1118 Lining Up

摘要: #include<iostream>using namespace std;double c[702][2];//坐标数组double k[702];//斜率数组int cmp( const void* a , const void* b ) { return *(double *)a > *(double *)b ? 1 : -1; } int main(){ int n,cnt,max,num; while(cin >> n) { if(n == 0)break; for(int i = 1;i <= n; ++i) cin >> c[i][ 阅读全文

posted @ 2011-07-17 23:47 sysu_mjc 阅读(143) 评论(0) 推荐(0) 编辑

上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 57 下一页

导航