C - Repunit Trio Editorial by evima
Another Solution by ProposerThe rephrasing of the condition in the official editorial is probably unnecessary given the constraints this time. Since the sample input and output show that there is no need to consider repunits with \(13\) or more digits, it is sufficient to try all ways to choose three from \(1, 11, 111, \dots, 111111111111\).
Sample Implementation (Python)
N = int(input())
L = 12
r = [int("1" * (i + 1)) for i in range(L)]
s = set()
for i in range(L):
for j in range(L):
for k in range(L):
s.add(r[i] + r[j] + r[k])
print(sorted(s)[N - 1])
N = int(input())
L = 12
r = [int("1" * (i + 1)) for i in range(L)]
for i in range(L):
for j in range(i + 1):
for k in range(j + 1):
N -= 1
if N == 0:
print(r[i] + r[j] + r[k])
posted:
last update: