您的位置:首页 > 其它

【codeforces】The Text Splitting

2016-07-21 22:49 429 查看








怎么说呢,此题我的代码略乱,就是求二元一次方程

#include<stdio.h>
#include<string.h>
char c[106];
int main() {
int n,p,q;
while(scanf("%d %d %d",&n,&p,&q)!=EOF) {
getchar();
int k=0,t=0;
for(int l=0;l<n;l++){
scanf("%c",&c[l]);
}
for(int i=0; i<=n/p; i++) {
for(int j=0; j<=n/q; j++) {
if(i*p+j*q==n) {
k=i;
t=j;
}
}
}
if(k==0&&t==0)
printf("-1\n");
else {
printf("%d\n",k+t);
for(int l=0; l<k; l++) {
for(int j=0; j<p; j++)
printf("%c",c[l*p+j]);
printf("\n");
}
for(int l=0;l<t;l++)
{
for(int j=0;j<q;j++)
printf("%c",c[l*q+j+k*p]);
printf("\n");
}
}
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  codeforces