2 solutions
-
3
这题的核心思路就是用题目的提示来判断能不能填充1 直接来看代码(此代码为不要三个一的目前最短代码 但不是最快的)
#include<cstdio> char s[101];int n,m,a,i; main(){freopen("three.in","r",stdin);freopen("three.out","w",stdout);scanf("%d%d",&n,&m);for(i=0;i<n&&a<m;++i)if(i<2||!(s[i-1]=='1'&&s[i-2]=='1'))s[i]='1',a++;else s[i]='0';while(i<n)s[i++]='0';printf("%s",s);}
Information
- ID
- 4487
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 5
- Tags
- (None)
- # Submissions
- 146
- Accepted
- 60
- Uploaded By