摘要: 地址: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)
摘要: 地址:http://codeforces.com/contest/267/problem/A更相减损,也是求最大公约数的方法,本题求用了多少次减法用辗转相除也是可以的,相当于把每一步求余时的商相加担心很大的数相除会出问题,所以用long long 1 #include<stdio.h> 2 3 int n; 4 long long a,b; 5 6 int main() 7 { 8 long long i,t,ans; 9 scanf("%d",&n);10 for(i=0;i<n;i++)11 {12 ans=0;13 sc... 阅读全文
posted @ 2013-01-18 20:58 tjsuhst 阅读(234) 评论(0) 推荐(0)
摘要: 地址:http://codeforces.com/contest/257/problem/A快排(一开始快排还写错了,死循环),然后就是比较所需插孔和已有插孔的个数了注意别忘了不需要排插的情况,此时答案为0 1 #include<stdio.h> 2 3 int n,m,k; 4 int f[50]; 5 6 int ones(int l,int r) 7 { 8 int i=l,j=r,flag=0,key=f[l]; 9 int t1;10 while(i<j)11 {12 if(0==flag)13 {14 ... 阅读全文
posted @ 2013-01-18 15:22 tjsuhst 阅读(185) 评论(0) 推荐(0)