cjweffort

博客园 首页 联系 订阅 管理

2013年3月14日

摘要: // 1031. Hello World for U.cpp: 主项目文件。 #include "stdafx.h" #include #include int main() { int n1,n2; const int N=83; char ss[N][N],str[N]; for(int i=0;in1) n1=k; } } n2=length+2-2*n1; int cnt=0; for(int i=0;i=0;j--) ss[j][n2-1]=str[cnt++]; for(int i=0;i<n1;i++){ ss[i][n2]='... 阅读全文
posted @ 2013-03-14 23:46 cjweffort 阅读(156) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?pid=1347用getchar读取数据居然可以少这么多,比起scanf整整少了320ms并查集优化:(1)路径压缩我们找到最久远的祖先时“顺便”把它的子孙直接连接到它上面int findSet(int x){ if(fa[x]==-1) return x; int ret=findSet(fa[x]); fa[x]=ret; return ret; }(2)Rank合并合并时将元素所在深度低的集合合并到元素所在深度高的集合void unionSet(int x,int y,int dd){ int root1=fi... 阅读全文
posted @ 2013-03-14 18:42 cjweffort 阅读(137) 评论(0) 推荐(0) 编辑

摘要: study disjoint-set data stucture:the key of solving this problem is the strategy to set and compute every equivalence class‘s member numbers.// 1034. Head of a Gang.cpp: 主项目文件。 #include "stdafx.h" #include #include #include #include #include #include #include using namespace std; const int 阅读全文
posted @ 2013-03-14 17:13 cjweffort 阅读(149) 评论(0) 推荐(0) 编辑

摘要: To find the first common node on the two link list;// 题目1468:Sharing.cpp: 主项目文件。 //#include "stdafx.h" #include #include using namespace std; const int N=100003; typedef struct Node { int add,next; }Node; Node node[N]; Node list1[N],list2[N]; int n; bool cmp(Node m1, Node m2) { return m1.a 阅读全文
posted @ 2013-03-14 10:17 cjweffort 阅读(162) 评论(0) 推荐(0) 编辑

摘要: cars refueling problem:with greedy algorithmgo tohttp://blog.csdn.net/newner/article/details/8637065 阅读全文
posted @ 2013-03-14 10:13 cjweffort 阅读(104) 评论(0) 推荐(0) 编辑

摘要: //sort// 1025. PAT Ranking.cpp: 主项目文件。 #include "stdafx.h" #include #include #include using namespace std; const int N=30003; struct Info{ char id[14]; int score; int belongs,vRank; int rank; Info operator=(const Info &info){ strcpy(id,info.id); score=info.score; belongs=info.belongs.. 阅读全文
posted @ 2013-03-14 10:08 cjweffort 阅读(124) 评论(0) 推荐(0) 编辑

摘要: // 1027. Colors in Mars.cpp: 主项目文件。 #include "stdafx.h" #include void read(int *p){ scanf("%d",p); } void transfer(int num){ if(num==0){ printf("00"); return; } char aa[5],cnt=0; int tt=num/13; if(tt>=0&&tt=0&&tt<=9) aa[1]=tt+'0'; else aa[1 阅读全文
posted @ 2013-03-14 08:39 cjweffort 阅读(133) 评论(0) 推荐(0) 编辑

摘要: 1001. A+B Formathttp://blog.csdn.net/newner/article/details/86713281002. A+B forPolynomialshttp://blog.csdn.net/newner/article/details/86713301003 Emergencehttp://blog.csdn.net/newner/article/details/86551141004. CountingLeaveshttp://blog.csdn.net/newner/article/details/86551321005. Spell ItRighthtt 阅读全文
posted @ 2013-03-14 08:17 cjweffort 阅读(127) 评论(0) 推荐(0) 编辑

摘要: // 1009. Product of Polynomials.cpp: 主项目文件。 #include "stdafx.h" #include #include void read(double *aa, int n){ for(int i=0;i=0;i--){ if(sum[i]!=0) printf(" %d %.1lf",i,sum[i]); } printf("\n"); } return 0; } 阅读全文
posted @ 2013-03-14 08:10 cjweffort 阅读(133) 评论(0) 推荐(0) 编辑

摘要: // 1006. Sign In and Sign Out.cpp: 主项目文件。 #include "stdafx.h" #include #include const int N=1003; typedef struct Person{ char id[17]; char start[10],end[10]; }Person; Person person[N]; int n; void selectMinAndMax(){ char min[10],max[10]; int minf=0,maxf=0; strcpy(min,person[0].start); str. 阅读全文
posted @ 2013-03-14 08:09 cjweffort 阅读(171) 评论(0) 推荐(0) 编辑

摘要: // 1005. Spell It Right.cpp: 主项目文件。 #include "stdafx.h" #include #include #include #include #include using namespace std; map cmap; void operate(int sum){ if(sum==0){ puts("zero"); return; } int aa[4],cnt=0; memset(aa,0,sizeof(aa)); while(sum){ aa[cnt++]=sum%10; sum/=10; } for... 阅读全文
posted @ 2013-03-14 08:08 cjweffort 阅读(184) 评论(0) 推荐(0) 编辑

摘要: // 1002. A+B for Polynomials.cpp: 主项目 文件。 #include "stdafx.h" #include #include void read(double *aa, int n){ for(int i=0;i=0;i--){ if(sum[i]!=0) printf (" %d %.1lf",i,sum[i]); } printf("\n"); } return 0; } 阅读全文
posted @ 2013-03-14 08:03 cjweffort 阅读(142) 评论(0) 推荐(0) 编辑

摘要: // 1001. A+B Format.cpp: 主项目文件。 #include "stdafx.h" #include int main() { char str[11]; int a,b; while(~scanf("%d%d",&a,&b)){ int sum=a+b; if(sum==0){ printf("0\n"); continue; } if(sum=0;i--){ putchar(str[i]); if(i%3==0&&i!=0) putchar(','); } put 阅读全文
posted @ 2013-03-14 08:01 cjweffort 阅读(162) 评论(0) 推荐(0) 编辑