难得一次比赛能够自己成功A掉四个题;
A题:水题,模拟一下就行;
1 #include2 #include 3 using namespace std; 4 5 void print(int x) 6 { 7 if(x>=5){printf("-O|");x%=5;} 8 else printf("O-|"); 9 if(x==0)puts("-OOOO");10 else if(x==1)puts("O-OOO");11 else if(x==2)puts("OO-OO");12 else if(x==3)puts("OOO-O");13 else if(x==4)puts("OOOO-");14 }15 16 int n;17 int main()18 {19 scanf("%d",&n);20 while(n/10>0)21 {22 int x=n%10;23 print(x);24 n/=10;25 }26 print(n);27 return 0;28 }
B:水题,边输入边统计就行:
1 By yours1103, contest: Codeforces Round #211 (Div. 2), problem: (B) Fence, Accepted, # 2 #include3 #include 4 #define maxn 150005 5 using namespace std; 6 7 int n,k,ans,num[maxn],tt,mi; 8 int main() 9 {10 scanf("%d%d",&n,&k);11 tt=k-1;12 for(int i=0; i
C:水题,对于连续的数量大于1的字符,最好的情况是212121····
1 #include2 #include 3 #define maxn 200009 4 using namespace std; 5 6 char s[maxn],t[maxn]; 7 int co[maxn]; 8 int cnt,num; 9 10 int main()11 {12 scanf("%s",s);13 int l=strlen(s);14 t[cnt]=s[0];15 num=1;16 for(int i=1;i
D:二分+贪心的题。挺简单的
1 #include2 #include 3 #include 4 #define maxn 100005 5 using namespace std; 6 7 int p[maxn],v[maxn],a; 8 int n,m; 9 bool vis[maxn];10 bool ok(int x)11 {12 int tmp=a;13 int cnt=1;14 memset(vis,0,sizeof vis);15 for(int i=x-1;i>=0;i--)16 {17 if(p[n-cnt] >1;37 if(ok(mid))l=mid+1;38 else r=mid-1;39 }40 int sum=0,tt;41 for(int i=0;i a)tt=sum-a;44 else tt=0;45 printf("%d %d\n",r,tt);46 return 0;47 }