-
Notifications
You must be signed in to change notification settings - Fork 0
/
E.cpp
50 lines (49 loc) · 1012 Bytes
/
E.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
int main() {
int k,a,b,i,n,x,c[300],sum;
string s;
cin>>k>>a>>b;
cin>>s;
n=s.size();
if(n<k*a || n>k*b)
cout<<"No solution\n";
else
{
x=n/k;
if((b-x)*k<n%k)
cout<<"No solution\n";
else
{
for(i=0;i<k;i++)
c[i]=x;
sum=x*k;
for(i=0;i<k;i++)
{
if(sum+b-x>=n)
{
c[i]+=n-sum;
break;
}
else
{
c[i]=b;
sum+=b-x;
}
}
for(i=1;i<k;i++)
c[i]+=c[i-1];
int st=0;
for(i=0;i<n;i++)
{
if(i==c[st])
{
cout<<"\n";
st++;
}
cout<<s[i];
}
}
}
return 0;
}