4 solutions
-
5
这题的核心思路就是用题目的提示来判断能不能填充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);} -
1
这道题怎么压最短? 老学弟的肯定
#import<ios> 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<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);}切记“能运行就是好代码”
-
0
- 1
Information
- ID
- 4487
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 8
- Tags
- (None)
- # Submissions
- 550
- Accepted
- 78
- Uploaded By