Arcesium | Online Assessment
Anonymous User
5497

You are given two strings S and T. An infinitely long string is formed in the following manner:

Take an empty string
Append S one time.
Append T two times.
Append S three times.
Append T four times.
and so on, appending the strings alternately and increasing the number of repetitions by 1 each time.

You will also be given an integer K, you need to tell the Kth Character of this infinitely long string.

Sample Input:
S = "a", T = "bc", K = 4

Sample Output:
b

Sample Explanation:
The string formed will be "abcbcaaabcbcbcbcaaaaa...". So the 4th character is "b".

[execution time limit] 1 seconds (cpp)

[input] string s

The first string. 1 <= len(S) <= 100

[input] string t

The second string. 1 <= len(T) <= 100.

[input] integer64 k

The integer K, as above.
1 <= K <= 10^16

[output] char

The kth character of the infinitely long string formed.

Comments (12)