【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 Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- Codeforces Round #349 (Div. 2) - C
- Codeforces Round #361 (Div. 2)
- 7.13Codeforces Round #360 (Div. 2)
- Codeforces Round #363 (Div. 2)
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)