-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstruct the String
More file actions
46 lines (44 loc) · 851 Bytes
/
Construct the String
File metadata and controls
46 lines (44 loc) · 851 Bytes
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
import java.util.*;
public class problem1335B
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int t = 0, n = 0, a = 0, b = 0;
t = in.nextInt();
for (int i = 0; i < t; i++)
{
String str = "";
n = in.nextInt();
a = in.nextInt();
b = in.nextInt();
if (a == b)
{
char start = 'a';
for (int j = 0; j < n; j++)
{
if (start == (char)('z' + 1)) { start = 'a'; }
str += start; start += 1;
}
System.out.println(str);
}
else if (b == 1)
{
for (int j = 0; j < n; j++) { str += 'a';}
System.out.println(str);
}
else
{
int offset = 0;
char start = 'a';
for (int j = 0; j < n; j++)
{
if (offset == b) { offset = 0; }
str += (char)(start + offset);
offset += 1;
}
System.out.println(str);
}
}
}
}