Advertisement
Saleh127

Untitled

Apr 15th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int b,c[26]={0},d,e,f,i,j,k,l;
  6. string a;
  7. cin>>b;
  8. cin>>a;
  9. if(b==1){cout<<a<<endl; return 0;}
  10. l=a.size();
  11. for(i=0;i<l;i++)
  12. {
  13. c[a[i]-'a']++;
  14. }
  15. for(j=0;j<26;j++)
  16. {
  17. if(c[j]%b)
  18. {cout<<-1<<endl; return 0;}
  19. else c[j]/=b;
  20. /*if(c[j]>0)
  21. {
  22. for(j=0; j<c[j]/b; j++)
  23. ans[x++]=i+'a';
  24. }
  25. loop()
  26. {
  27. print ans;
  28. }
  29. */
  30. }
  31. for(i=0;i<b;i++)
  32. {
  33. for(j=0;j<26;j++)
  34. {
  35. for(k=0;k<c[j];k++)
  36. {
  37. printf("%c",j+97);
  38. }
  39. }
  40. }
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement