atcoder#CODEFESTIVAL2017QUALBF. Largest Smallest Cyclic Shift
Largest Smallest Cyclic Shift
Score : points
Problem Statement
For a string , let be the lexicographically smallest cyclic shift of .
For example, if babca
, ababc
because this is the smallest among all cyclic shifts (babca
, abcab
, bcaba
, cabab
, ababc
).
You are given three integers , and .
You want to construct a string that consists of exactly a
s, exactly b
s, and exactly c
s.
If there are multiple such strings, you want to choose one that maximizes lexicographically.
Compute the lexicographically largest possible value of .
Constraints
- are non-negative integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 2 0
abab
must consist of two a
s and two b
s.
- If
aabb
,aabb
. - If
abab
,abab
. - If
abba
,aabb
. - If
baab
,aabb
. - If
baba
,abab
. - If
bbaa
,aabb
.
Thus, the largest possible is abab
.
1 1 1
acb