摘要: 地址: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)
摘要: 地址:http://codeforces.com/contest/242/problem/A裁判不记得投硬币游戏最后的详细信息,只记得一些大概情况,输出所有可能情况 1 #include<stdio.h> 2 3 int x,y,a,b; 4 5 int main() 6 { 7 int i,j,n=0; 8 scanf("%d %d %d %d",&x,&y,&a,&b); 9 for(i=a;i<=x;i++)10 for(j=b;j<=y;j++)11 {12 if(i>j) n++;13 ... 阅读全文
posted @ 2013-01-20 22:52 tjsuhst 阅读(141) 评论(0) 推荐(0)
摘要: 地址:http://hustoj.sinaapp.com/problem.php?id=1833动态规划a[i][j]储存输入的金字塔,F[i][j]储存a[i][j]处能达到的最大值状态方程:F[i][j]=max{F[i+1][j], F[i+1][j+1]}+a[i][j] 1 #include<stdio.h> 2 int n; 3 int a[1000][1000]={0},F[1000][1000]={0}; 4 5 int main() 6 { 7 int i,j; 8 scanf("%d",&n); 9 for(i=0;i<n;i+ 阅读全文
posted @ 2013-01-20 10:48 tjsuhst 阅读(209) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/246/problem/A很明显是一个错误的冒泡排序,想输出非减序列,但是大数字沉底后仍然进入了下一次排序给一个递减序列就能指出这个算法的错误 1 #include<stdio.h> 2 3 int n; 4 5 int main() 6 { 7 int i; 8 scanf("%d",&n); 9 for(i=0;i<n;i++)10 {11 if(1==n || 2==n) {printf("-1");break;}12 printf("%d &qu 阅读全文
posted @ 2013-01-19 23:24 tjsuhst 阅读(204) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/250/problem/A将一个数列分割,每个子数列中负数个数不能多于两个,输出分割的块数,依次输出每个子数列的长度 1 #include<stdio.h> 2 3 int n,d[100]; 4 5 int main() 6 { 7 int i,j=0,in,count=0; 8 scanf("%d",&n); 9 for(i=0;i<n;i++)10 {11 scanf("%d",&in);12 if(in<0) count++;13 if(.. 阅读全文
posted @ 2013-01-18 22:55 tjsuhst 阅读(149) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/248/problem/A开关壁橱的左右门使左右各自的闭合情况一样,输出最少动作次数统计左,右的各自的和,过半则用n减 1 #include<stdio.h> 2 3 int n; 4 5 int main() 6 { 7 int i,a,b,l=0,r=0; 8 scanf("%d",&n); 9 for(i=0;i<n;i++)10 {11 scanf("%d %d",&a,&b);12 l+=a;13 r+=b;14 }15 ... 阅读全文
posted @ 2013-01-18 22:23 tjsuhst 阅读(155) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/252/problem/A求连续子序列xor的最大值最开始理解错题意了 1 #include<stdio.h> 2 3 int n,a[100]; 4 5 int main() 6 { 7 int i,j,k,t,ans=0; 8 scanf("%d",&n); 9 for(i=0;i<n;i++)10 {11 scanf("%d",&a[i]);12 }13 for(i=1;i<=n;i++)14 {15 for(j=0;j<=n-i;... 阅读全文
posted @ 2013-01-18 21:55 tjsuhst 阅读(157) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/254/problem/A这题昨天就在想,想复杂了一些一个5000的数组用来存数字的位数,一个400000x2的二维数组用来存答案(400000稍大了些)读每个数第一次读入时,先将其位置存到5000数组里,第二次读入时,一起转到二维数组中,然后5000数组相应位置清零所有数据读完后,检查5000数组,全为零则可以输出答案,否则输出-1 1 #include<stdio.h> 2 3 int n,a[5001],ans[400000][2]; 4 5 int main() 6 { 7 int i,in,j=0,flag 阅读全文
posted @ 2013-01-18 21:22 tjsuhst 阅读(169) 评论(0) 推荐(0)