摘要: 地址:http://codeforces.com/contest/265/problem/B爬树吃坚果,很明显树顶走是最短路 1 #include<stdio.h> 2 3 int n,h[2]; 4 5 int main() 6 { 7 int i,ans=0; 8 scanf("%d",&n); 9 for(i=0;i<n;i++)10 {11 scanf("%d",&h[1]);12 if(0==i)13 {14 ans=h[1]+1;15 h[0]=h[1... 阅读全文
posted @ 2013-01-21 23:33 tjsuhst 阅读(306) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/233/problem/A这题好像做过,接下来几天要做点有难度的题 1 #include<stdio.h> 2 3 int n; 4 5 int main() 6 { 7 int i; 8 scanf("%d",&n); 9 if(n%2==0)10 {11 for(i=1;i<=n;i=i+2)12 printf("%d %d ",i+1,i);13 }14 else printf("-1\n");15 return 0;16 ... 阅读全文
posted @ 2013-01-21 22:50 tjsuhst 阅读(156) 评论(0) 推荐(1)
摘要: 地址:http://codeforces.com/contest/234/problem/A排座位,左右撇子都有,要求每两个人坐一起手不打架 1 #include<stdio.h> 2 3 int n; 4 5 int main() 6 { 7 int l,r; 8 char in[101]; 9 freopen("input.txt","r",stdin);10 freopen("output.txt","w",stdout);11 scanf("%d",&n);12 sc 阅读全文
posted @ 2013-01-21 22:41 tjsuhst 阅读(242) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/239/problem/A按题目说的求就是了 1 #include<stdio.h> 2 3 int y,k,n; 4 5 int main() 6 { 7 int i; 8 scanf("%d %d %d",&y,&k,&n); 9 i=(y/k+1)*k-y;10 if(i>n-y) printf("-1\n");11 else12 {13 while(i<=n-y)14 {15 printf("%d ",i);16 阅读全文
posted @ 2013-01-21 18:01 tjsuhst 阅读(169) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/265/problem/A昨晚没时间参赛 1 #include<stdio.h> 2 #include<string.h> 3 4 char a[50],b[50]; 5 6 int main() 7 { 8 int i=0,j=0,len; 9 scanf("%s",a);10 scanf("%s",b);11 len=(int)strlen(b);12 for(j=0;j<len;j++)13 {14 if(b[j]==a[i]) i++;15 }1... 阅读全文
posted @ 2013-01-21 11:56 tjsuhst 阅读(163) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/237/problem/A想服务所有顾客,要多少cash,同时来的肯定不能在同一台cash上这题我错了好多次才AC...... 1 #include<stdio.h> 2 3 int a,b,c,d,n; 4 5 int main() 6 { 7 int i,count=1,ans=0; 8 scanf("%d",&n); 9 for(i=0;i<n;i++)10 {11 scanf("%d %d",&c,&d);12 if(i==0)13 {1. 阅读全文
posted @ 2013-01-21 01:38 tjsuhst 阅读(159) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/236/problem/A要求统计一串字符中出现了多少个字母 1 #include<stdio.h> 2 3 int a[26]; 4 5 int main() 6 { 7 int count=0; 8 char in; 9 in=getchar();10 while(in-'a'>=0 && in-'a'<26)11 {12 if(0==a[in-'a'])13 {14 count++;15 a[in-'... 阅读全文
posted @ 2013-01-21 01:20 tjsuhst 阅读(132) 评论(0) 推荐(0)
摘要: 地址:http://www.rqnoj.cn/Problem_53.html其实每种状态只与两个因素有关:栈里元素的个数,未入栈的元素个数 1 #include<stdio.h> 2 3 int n,a[20][20]; 4 5 int search(int keng,int right) 6 { 7 if(a[keng][right]!=0) return a[keng][right]; 8 if(right==0 && keng!=0) return 1; 9 else if(right!=0 && keng==0) return a[keng] 阅读全文
posted @ 2013-01-21 00:45 tjsuhst 阅读(181) 评论(0) 推荐(0)