上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 57 下一页

2011年7月18日

poj 2039 To and Fro

摘要: #include <iostream>#include <string>using namespace std;int main(){ int interval,row,i,j; char str[210]; while(cin>>interval&&interval) { cin>>str; row=strlen(str)/interval; for(i=0;i<interval;i++) for(j=0;j<row;j++) { if(j%2==0) cout<<str[interval*j+i]; e 阅读全文

posted @ 2011-07-18 11:33 sysu_mjc 阅读(112) 评论(0) 推荐(0) 编辑

poj 2013 Symmetric Order

摘要: #include <iostream>#include <string>using namespace std;int main(){ char str[20][30]; int flag[20]; int n,t=1,i; while(cin>>n&&n) { cout<<"SET "<<t++<<endl; fill(flag,flag+20,1); for(int i=1;i<=n;i++) { cin>>str[i]; if(i%2==1) { flag[i]= 阅读全文

posted @ 2011-07-18 11:31 sysu_mjc 阅读(112) 评论(0) 推荐(0) 编辑

poj 1833 排列

摘要: #include <iostream>#include <algorithm>using namespace std;int main(){ int m,n,k,i,list[1024]; cin>>m;while(m--) { scanf("%d%d",&n,&k); for(i=0;i<n;i++) scanf("%d",&list[i]); while(k--) next_permutation(list,list+n); for(i=0;i<n;i++) printf(&qu 阅读全文

posted @ 2011-07-18 11:30 sysu_mjc 阅读(73) 评论(0) 推荐(0) 编辑

poj 1961 Period

摘要: #include <iostream> //KMP算法,参考poj 2406 Power Stringsusing namespace std;char B[2000000]; int m,next[2000000]; void get_next(){ next[1]=0; int j=0; for(int i=2;i<=m;++i) { while(j>0&&B[j+1]!=B[i]) j=next[j]; if(B[j+1]==B[i]) j=j+1; next[i]=j; }}int main(){ int num=1; while(scanf(& 阅读全文

posted @ 2011-07-18 11:30 sysu_mjc 阅读(102) 评论(0) 推荐(0) 编辑

poj 1716 Integer Intervals

摘要: //贪心,按区间的终止点(右边的点)从小到大排列,我们每次取区间最右边的点,使这个区间内至少有两个点在s中#include <iostream> #include <algorithm>using namespace std;struct node { int x;int y; bool operator<(const node& n)const { return y<n.y; }}interval[10001];int res[10001];int main(){ int n,i,j,ans,top=-1; cin>>n; for(i= 阅读全文

posted @ 2011-07-18 11:29 sysu_mjc 阅读(123) 评论(0) 推荐(0) 编辑

poj 1617 Crypto Columns

摘要: #include <iostream>#include <algorithm>#include <string>using namespace std;int main(){ char ch[12],cpy[12],letter[110]; int list[12],tag[12],i,j; while(cin>>ch&&strcmp(ch,"THEEND")!=0) { cin>>letter; strcpy(cpy,ch); sort(ch,ch+strlen(ch)); memset(tag, 阅读全文

posted @ 2011-07-18 11:28 sysu_mjc 阅读(154) 评论(0) 推荐(0) 编辑

poj 1611 The Suspects

摘要: // 题意: 一共有n个学生(编号0 至 n-1),m个组,一个学生可以同时加入不同的组。// 问有多少人与0号学生属于同一组#include <iostream> //并查集using namespace std;#define maxn 30002 int p[maxn],hei[maxn],n; int m,node[maxn];void init(){ for(int i=0;i<n;++i) //结点下标从0到n-1 { p[i]=i; hei[i]=0; }}int find(int x){ return... 阅读全文

posted @ 2011-07-18 11:27 sysu_mjc 阅读(123) 评论(0) 推荐(0) 编辑

poj 1595 Prime Cuts

摘要: #include <iostream>#include <math.h>using namespace std;bool isprime(int n){ for (int i=2;i<=sqrt((double)n);i++) { if(n%i==0) return false; } return true;}int list[500];int main(){ int N,C,i,j,top=0; list[0]=0; while(cin>>N>>C) { if(list[top]<N) { int t=list[top]; for( 阅读全文

posted @ 2011-07-18 11:26 sysu_mjc 阅读(117) 评论(0) 推荐(0) 编辑

poj 1579 Function Run Fun

摘要: #include <iostream>using namespace std;int rec[21][21][21];int w(int a,int b,int c){ if(a<=0||b<=0||c<=0) return 1; else if(a>20||b>20||c>20) return w(20,20,20); else if(rec[a][b][c]!=-1) return rec[a][b][c]; else { int s; if(a<b&&b<c) s=w(a,b,c-1)+w(a,b-1,c-1)- 阅读全文

posted @ 2011-07-18 11:25 sysu_mjc 阅读(102) 评论(0) 推荐(0) 编辑

poj 1564 Sum It Up

摘要: #include<iostream> //有重复的深搜剪枝 using namespace std; int mount,pre_value,mark;int a[12][2];void output(){ mark++; int flag=0; for(int i=0;i<mount;i++) { if(a[i][1]) { if(flag++) cout<<"+"; cout<<a[i][0]; } } cout<<endl; }void dfs(int sum,int now_value,int pre){ if( 阅读全文

posted @ 2011-07-18 11:24 sysu_mjc 阅读(181) 评论(0) 推荐(0) 编辑

上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 57 下一页

导航