Problem: 1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:    * the dogs numbered 1,2,\cdots,26 were respectively given the names `a`, `b`, ..., `z`;   * the dogs numbered 27,28,29,\cdots,701,702  were respectively given the names `aa`, `ab`, `ac`, ..., `zy`, `zz`;   * the dogs numbered 703,704,705,\cdots,18277,18278  were respectively given the names `aaa`, `aab`, `aac`, ..., `zzy`, `zzz`;   * the dogs numbered 18279,18280,18281,\cdots,475253,475254  were respectively given the names `aaaa`, `aaab`, `aaac`, ..., `zzzy`, `zzzz`;   * the dogs numbered 475255,475256,\cdots  were respectively given the names `aaaaa`, `aaaab`, ...;   * and so on.  To sum it up, the dogs numbered 1, 2, \cdots were respectively given the following names:  `a`, `b`, ..., `z`, `aa`, `ab`, ..., `az`, `ba`, `bb`, ..., `bz`, ..., `za`, `zb`, ..., `zz`, `aaa`, `aab`, ..., `aaz`, `aba`, `abb`, ..., `abz`, ..., `zzz`, `aaaa`, ...  Now, Roger asks you:  "What is the name for the dog numbered N?"

Submission attempts (in order):
N = input()

s = "abcdefghijklmnopqrstuvwxyz"
ans = ""
n, m = 0, 0

for i in range(1, 1000):
    m += 26 ** i
    if N <= m:
        n = i
        break

for i in range(n):
    a, b = divmod(N, 26)
    N = a
    if b == 0:
        ans += s[25]
        N -= 1
    else:
        ans += s[b-1]

ans1 = ''.join(list(reversed(ans)))
print(ans1)

N = 1000

s = "abcdefghijklmnopqrstuvwxyz"
ans = ""
M, n, m = 0, 0, 0

for i in range(1, 1000):
    m += 26**i
    if N <= m:
        M = N + 26**i -m
        n = i - 1
        break

for i in reversed(range(n + 1)):
    a, b = divmod(M, 26**i)
    M = b
    if i == 0:
        ans += s[a-1]
    else:
        ans += s[a]

print(ans)

N = int(input())
 
s = "abcdefghijklmnopqrstuvwxyz"
ans = ""
n, m = 0, 0
 
for i in range(1, 1000):
    m += 26**i
    if N <= m:
        n = i -1
        break

for i in reversed(range(n)):
    a, b = divmod(N, 26**i)
    N = b
    if not a ==0:
      ans += s[a-1]
    else:
      ans += s[25]

print(ans)

N = input()
 
s = "abcdefghijklmnopqrstuvwxyz"
m = 0
ans = ""
M,n = 0,0

for i in range(1,1000):
  m += 26**i
  if N <= m:
    M = N + 26**i　- m
    n = i-1
    break

for i in reversed(range(n+1)):
  a, b = divmod(M, 26**i)
  M = b
  ans = ans + s[a]

print(ans)

N = map(int, input())
 
s = "abcdefghijklmnopqrstuvwxyz"
m = 0
ans = ""
 
for i in range(1,1000):
  m += 26**i
  if N <= m:
    M = N + 26**i　- m
    n = i-1
    break

for i in reversed(range(n)):
  a, b = divmod(M, 26**i)
  M = b
  ans = ans + s[a]

print(ans)

N = map(int, input())

C = "abcdefghijklmnopqrstuvwxyz"
m = 0
ans = ""

for i in range(1,1000):
  m += 26**i
  if N <= m:
    M = N - m + 26**i
    n = i-1
    break

for i in revesed(range(n)):
  a, b = divmod(M, 26**i)
  M = b
  ans = ans + C[a]

print(ans)
  

N = input()

s = "abcdefghijklmnopqrstuvwxyz"
ans = ""
M, n, m = 0, 0, 0

for i in range(1, 1000):
    m += 26**i
    if N <= m:
        M = N + 26**i -m
        n = i - 1
        break

for i in reversed(range(n + 1)):
    a, b = divmod(M, 26**i)
    M = b
    if i == 0:
        ans += s[a-1]
    else:
        ans += s[a]

print(ans)

N = int(input())

s = "abcdefghijklmnopqrstuvwxyz"
ans = ""
n, m = 0, 0

for i in range(1, 1000):
    m += 26 ** i
    if N <= m:
        n = i
        break

for i in range(n):
    a, b = divmod(N, 26)
    N = a
    if b == 0:
        ans += s[25]
        N -= 1
    else:
        ans += s[b-1]

ans1 = ''.join(list(reversed(ans)))
print(ans1)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted