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):
def print_ans(num):

    base = 26

    checker = True
    ind = 1
    while checker:
        if num > base ** ind:
            ind += 1
        else:
            checker = False
            ind -= 1

    pre_ans_num = []
    for i in range(ind):
        ind_2 = ind - i
        quot = num // base ** ind_2
        pre_ans_num.append(quot)
        num = num % base ** ind_2
    pre_ans_num.append(num)

    ans = ""
    
#     print(pre_ans_num)
    pre_ans_num2 = pre_ans_num.copy()
    for i , ans_num in enumerate(pre_ans_num):
#         print(i, ans_num)
        pre_ans_num2[i - 1] += -1
        
    for n in pre_ans_num2:
        if n==0:
            ans += "z"
        else:
            order = ord("a") + n - 1
            ans += chr(order)

    print(ans)

a = str(input())
print_ans(a)

num = int(input())
base = 26

checker = True
ind = 1
while checker:
  if num > base ** ind:
    ind += 1
  else:
    checker = False
    ind += -1

pre_ans_num = []
for i in range(ind):
  ind_2 = ind - i
  quot = num // base ** ind_2
  pre_ans_list.append(quot)
  num = a % base ** ind_2

ans = ""
for n in pre_ans_num:
  if n==0:
    ans += "0"
  else:
    order = ord("a") + n - 1
    ans += chr(order)

print(ans)
    

def print_ans(num):

    base = 26

    checker = True
    ind = 1
    while checker:
        if num > base ** ind:
            ind += 1
        else:
            checker = False
            ind -= 1

    pre_ans_num = []
    for i in range(ind):
        ind_2 = ind - i
        quot = num // base ** ind_2
        pre_ans_num.append(quot)
        num = num % base ** ind_2
    pre_ans_num.append(num)

    ans = ""
    
#     print(pre_ans_num)
    pre_ans_num2 = pre_ans_num.copy()
    for i , ans_num in enumerate(pre_ans_num):
#         print(i, ans_num)
        pre_ans_num2[i - 1] += -1
        
    for n in pre_ans_num2:
        if n==0:
            ans += "z"
        else:
            order = ord("a") + n - 1
            ans += chr(order)

    print(ans)
    
a = int(input())
print_ans(a)

num = int(input())
base = 26

checker = True
ind = 1
while checker:
  if num > base ** ind:
    ind += 1
  else:
    checker = False
    ind += -1

pre_ans_num = []
for i in range(ind):
  ind_2 = ind - i
  quot = num // base ** ind_2
  pre_ans_num.append(quot)
  num = num % base ** ind_2

ans = ""
for n in pre_ans_num:
  if n==0:
    ans += "0"
  else:
    order = ord("a") + n - 1
    ans += chr(order)

print(ans)
    


N = int(input())
ans = ''
for i in range(1, 10000):
#     print(N)
#     print("-> ",26 ** i)
    if N <= 26 ** i: 
#         print("ok")
        N += -1
        for j in range(i):
#             print("N:", N)
#             print("N % 26:", N % 26)
            ans += chr(ord('a') + N % 26)
            N = N // 26  
        break
    else:
        N -= 26 ** i

print(ans[::-1])

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted