You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
530 B
C++
25 lines
530 B
C++
#include <cstdio>
|
|
#include <cstring>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
char buf[1005];
|
|
int c[127];
|
|
int main()
|
|
{
|
|
int k;
|
|
scanf("%d%s",&k,buf);
|
|
int len=strlen(buf);
|
|
if(len%k)
|
|
return puts("-1"),0;
|
|
for(int i=0; i<len; i++)
|
|
c[buf[i]]++;
|
|
for(int i='a'; i<='z'; i++)
|
|
if(c[i]%k)
|
|
return puts("-1"),0;
|
|
for(int i=0; i<k; i++)
|
|
for(int j='a'; j<='z'; j++)
|
|
for(int l=0; l<c[j]/k; l++)
|
|
putchar(j);
|
|
return 0;
|
|
}
|