Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// The text splitting
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- char s[101];
- int n,p,q,i,j,mul=1,m,chk,chk2;
- cin>>n>>p>>q;
- cin>>s;
- int sum =0;
- while(sum<n)
- {
- sum = mul*p + mul* q;
- mul++;
- }
- if(sum==n)
- {
- mul--;
- mul = mul*2;
- cout<<mul<<endl;
- i = 0;
- m=0;
- mul= mul/2;
- while(mul)
- {
- for(i; i<(m+p);i++)
- cout<<s[i];
- m = i;
- cout<<endl;
- for(j=i;j<(m+q);j++)
- cout<<s[j];
- m = i;
- cout<<endl;
- mul--;
- }
- }
- else
- {
- if(p>q)
- {
- chk = q;
- chk2 = p;
- }
- else
- {
- chk = p;
- chk2 = q;
- }
- if(n%chk==0)
- {
- mul = n/chk;
- cout<<mul<<endl;
- j=1;
- for(i=0;s[i]!='\0';i++,j++)
- {
- cout<<s[i];
- if(j==chk)
- {
- cout<<endl;
- j = 0;
- }
- }
- }
- else if(n%chk2==0)
- {
- mul = n/chk2;
- cout<<mul<<endl;
- j=1;
- for(i=0;s[i]!='\0';i++,j++)
- {
- cout<<s[i];
- if(j==chk2)
- {
- cout<<endl;
- j = 0;
- }
- }
- }
- else
- cout<<"-1";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement