Codeforces #360 A&B
传送门:http://codeforces.com/contest/688/problem/A
题目大意
Arya 有 n 个敌人和 d 天。
d 行 n 列,表示敌人的出勤情况
如果敌人不全勤,那么 Arya 可以击败所有敌人。
求 Arya 的最大连续击败敌人天数。
题解
模拟一下每一天统计即可
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include<cstdio> using namespace std; int n,d; int mul,Ans; bool pre[105][105]; char x; inline char read(){ x=getchar(); while(x!='0' && x!='1') x=getchar(); return x; } int main(){ scanf("%d%d",&n,&d); for (int i=1;i<=d;i++) for (int j=1;j<=n;j++){ if (read()=='0') pre[i][j]=false; else pre[i][j]=true; } mul=Ans=0; for (int i=1;i<=d;i++){ int cnt=0; for (int j=1;j<=n;j++) if (pre[i][j]) cnt++; if (cnt<n){ mul++; if (mul>Ans) Ans=mul; }else{ mul=0; } } printf("%d\n",Ans); return 0; } |
传送门:http://codeforces.com/contest/688/problem/B
题目大意
求第n大的偶数长度回文数
题解
输入什么就输出什么←_←
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<cstdio> #include<cstring> using namespace std; const int Maxn=100000+5; char num[Maxn]; int len; int main(){ scanf("%s",num); len=strlen(num); //printf("%d\n",len); for (int i=0;i<len;i++) printf("%c",num[i]); for (int i=len-1;i>=0;i--) printf("%c",num[i]); printf("\n"); return 0; } |

原文链接:Codeforces #360 A&B
WNJXYKの博客 版权所有,转载请注明出处。
还没有任何评论,你来说两句吧!