-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA. Chips.cs
48 lines (42 loc) · 1.16 KB
/
A. Chips.cs
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace ConsoleApplication25
{
class Program
{
static void Main(string[] args)
{
int kn = int.Parse(Console.ReadLine());
string line = Console.ReadLine();
int[] chars = new int[26];
for (int i = 0; i < line.Length;i++)
{
int pos = char.ToUpper(line[i]) - 64;
chars[pos - 1]++;
}
if (chars.Any(x => x % kn != 0))
{
Console.WriteLine(-1);
return;
}
var sb = new StringBuilder();
for (int k = 0; k < kn; k++)
{
for (int i = 0; i < 26; i++)
{
for (int j = 0; j < chars[i]/kn; j++)
{
char c = (char)('A' + (char)i);
sb.Append(char.ToLower(c));
}
}
}
Console.WriteLine(sb.ToString());
Console.ReadLine();
}
}
}