Problem:


Score : 300 points

Problem Statement

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?"

Constraints

N is an integer.

 1 \leq N \leq 1000000000000001

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer to Roger's question as a string consisting of lowercase English letters.

Sample Input 1

2

Sample Output 1

b

Sample Input 2

27

Sample Output 2

aa

Sample Input 3

123456789

Sample Output 3

jjddja



Sample input:
2


Sample output:
b

Submission status: Accepted

Solution code:
n = int(input())

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ans = ''


if n <= 26**1:
    # a-z
    for cnt in range(26):
        if n-1 == cnt:
            ans += alphabet[cnt]
elif 26**1 < n <= 26**2 + 26**1:
    # aa-zz
    for cnt in range(26):
        if 26*(cnt+1) < n <= 26*(cnt+2):
            ans += alphabet[cnt]
            n -= 26*(cnt+1)
    for cnt in range(26):
        if n-1 == cnt:
            ans += alphabet[cnt]
elif 26**2 + 26**1 < n <= 26**3 + 26**2 + 26**1:
    # aaa-zzz
    for cnt in range(26):
        if (26**2)*(cnt+1) < n <= (26**2)*(cnt+2)+26:
            ans += alphabet[cnt]
            n -= (26**2)*(cnt+1)
    for cnt in range(26):
        if 26*(cnt+1) < n <= 26*(cnt+2):
            ans += alphabet[cnt]
            n -= 26*(cnt+1)
    for cnt in range(26):
        if n-1 == cnt:
            ans += alphabet[cnt]
elif 26**3 + 26**2 + 26**1 < n <= 26**4 + 26**3 + 26**2 + 26**1:
    # aaaa-zzzz
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaa-zzzzz
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**5 + 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaaa-zzzzzz
    for cnt in range(26):
        if (26 ** 5) * (cnt + 1) < n <= (26 ** 5) * (cnt + 2) + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 5) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaaaa-zzzzzzz
    for cnt in range(26):
        if (26 ** 6) * (cnt + 1) < n <= (26 ** 6) * (cnt + 2) + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 6) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 5) * (cnt + 1) < n <= (26 ** 5) * (cnt + 2) + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 5) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaaaaaa-zzzzzzzz
    for cnt in range(26):
        if (26 ** 7) * (cnt + 1) < n <= (26 ** 7) * (cnt + 2) + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 7) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 6) * (cnt + 1) < n <= (26 ** 6) * (cnt + 2) + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 6) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 5) * (cnt + 1) < n <= (26 ** 5) * (cnt + 2) + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 5) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaaaaaaa-zzzzzzzzz
    for cnt in range(26):
        if (26 ** 8) * (cnt + 1) < n <= (26 ** 8) * (cnt + 2) + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 8) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 7) * (cnt + 1) < n <= (26 ** 7) * (cnt + 2) + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 7) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 6) * (cnt + 1) < n <= (26 ** 6) * (cnt + 2) + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 6) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 5) * (cnt + 1) < n <= (26 ** 5) * (cnt + 2) + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 5) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**10 + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaaaaaaaa-zzzzzzzzzz
    for cnt in range(26):
        if (26 ** 9) * (cnt + 1) < n <= (26 ** 9) * (cnt + 2) + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 9) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 8) * (cnt + 1) < n <= (26 ** 8) * (cnt + 2) + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 8) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 7) * (cnt + 1) < n <= (26 ** 7) * (cnt + 2) + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 7) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 6) * (cnt + 1) < n <= (26 ** 6) * (cnt + 2) + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 6) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 5) * (cnt + 1) < n <= (26 ** 5) * (cnt + 2) + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 5) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**10 + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**11 + 26**10 + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaaaaaaaaa-zzzzzzzzzzz
    for cnt in range(26):
        if (26 ** 10) * (cnt + 1) < n <= (26 ** 10) * (cnt + 2) + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 10) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 9) * (cnt + 1) < n <= (26 ** 9) * (cnt + 2) + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 9) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 8) * (cnt + 1) < n <= (26 ** 8) * (cnt + 2) + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 8) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 7) * (cnt + 1) < n <= (26 ** 7) * (cnt + 2) + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 7) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 6) * (cnt + 1) < n <= (26 ** 6) * (cnt + 2) + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 6) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 5) * (cnt + 1) < n <= (26 ** 5) * (cnt + 2) + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 5) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]
elif 26**11 + 26**10 + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1 < n <= 26**12 + 26**11 + 26**10 + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26**1:
    # aaaaaaaaaaaaa-zzzzzzzzzzzz
    for cnt in range(26):
        if (26 ** 11) * (cnt + 1) < n <= (26 ** 11) * (cnt + 2) + 26**10 + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 11) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 10) * (cnt + 1) < n <= (26 ** 10) * (cnt + 2) + 26**9 + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 10) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 9) * (cnt + 1) < n <= (26 ** 9) * (cnt + 2) + 26**8 + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 9) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 8) * (cnt + 1) < n <= (26 ** 8) * (cnt + 2) + 26**7 + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 8) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 7) * (cnt + 1) < n <= (26 ** 7) * (cnt + 2) + 26**6 + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 7) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 6) * (cnt + 1) < n <= (26 ** 6) * (cnt + 2) + 26**5 + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 6) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 5) * (cnt + 1) < n <= (26 ** 5) * (cnt + 2) + 26**4 + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 5) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 4) * (cnt + 1) < n <= (26 ** 4) * (cnt + 2) + 26**3 + 26**2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 4) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 3) * (cnt + 1) < n <= (26 ** 3) * (cnt + 2) + 26 ** 2 + 26:
            ans += alphabet[cnt]
            n -= (26 ** 3) * (cnt + 1)
    for cnt in range(26):
        if (26 ** 2) * (cnt + 1) < n <= (26 ** 2) * (cnt + 2) + 26:
            ans += alphabet[cnt]
            n -= (26 ** 2) * (cnt + 1)
    for cnt in range(26):
        if 26 * (cnt + 1) < n <= 26 * (cnt + 2):
            ans += alphabet[cnt]
            n -= 26 * (cnt + 1)
    for cnt in range(26):
        if n - 1 == cnt:
            ans += alphabet[cnt]

print(ans)

Submission status: Accepted

Solution code:
def main():
    a = [chr(ord('a') + i) for i in range(26)]
    a.insert(0,"a")
    list = []
    num = int(input()) 

    while(num > 0):
        if(num % 26 == 0):
            list.append(26)
            num = num // 26 -1
            continue
        else:
            list.append(num % 26)
        num = num // 26

    list.reverse()

    ans = []
    for i in range(0,len(list)):
        ans.append(a[list[i]])
    print(''.join(ans))
    


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)

num = int(input())
print(num2alpha(num))

Submission status: Accepted

Solution code:
num = int(input())
k=0
ans=[]
while k<1:
    if num<=26:
        ans.append((chr(96+num)))
        k=1
    elif num%26==0:
        num=(num//26-1)
        ans.append((chr(96+26)))
    else:
        ans.append((chr(96+num%26)))
        num=(num//26)

for i in range(len(ans)-1,-1,-1):
    if i ==0:
        print(ans[i])
    else:
        print(ans[i], end="")

Submission status: Accepted

Solution code:
# @author 

import sys

class COneQuadrillionAndOneDalmatians:
    def solve(self, tc=0):
        n = int(input()) - 1
        # for n in range(1000):
        sz = 1
        tot = 0
        while tot <= n:
            tot += 26 ** sz
            sz += 1
        sz -= 1

        ans = ""
        for i in range(1, sz):
            n -= 26 ** i
        for i in range(sz):
            ans += chr(ord('a') + (n // (26 ** (sz - i - 1))) % 26)

        print(ans)

solver = COneQuadrillionAndOneDalmatians()
input = sys.stdin.readline

solver.solve()

Submission status: Accepted

Solution code:
n=int(input())
ans=[' ' for _ in range(11)]
ans_=[]
letter=[' ','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
while n:
  new=n%26
  if new==0:
    new=26
    n+=-26
  ans_.append(new)  
  n=int(n/26)  
ans_=ans_[::-1]
for i in range(len(ans_)):
  ans[i]=letter[ans_[i]]
print(''.join(ans))

Submission status: Accepted

Solution code:
import sys
N=int(input())
"""
if N<=26:
  l=[]
  l.append(N)
  i=0
  print(chr(l[i]+96))
  sys.exit()
"""
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        if X_dumy%n==0:
          out= str(n)+','+out
          X_dumy = int(X_dumy//n)-1
        else:
          out = str(X_dumy%n)+','+out
          X_dumy = int(X_dumy//n)
    return out
ans=Base_10_to_n(N,26)
l=list(ans.split(","))
for i in range(len(l)-1):
  print(chr(int(l[i])+96),end="")

Submission status: Accepted

Solution code:
num = int(input())

def rec_get_k(n, current_under, current_k):
  next_k = current_k + 1
  curremt_upper = current_under + 26 ** next_k
  if n < curremt_upper and n >= current_under:
    return next_k
  else:
    return rec_get_k(n, curremt_upper, next_k)

use_k = rec_get_k(num, 1, 0)
use_num = num
res_list = []
tmp_k = use_k
for i in range(use_k):
  tmp_num = use_num % 26
  if tmp_num == 0:
    tmp_num = 26
  use_num -= tmp_num
  use_num = use_num // 26
  res_list.append(chr(96 + (tmp_num)))

res_list.reverse()
print("".join(res_list))

Submission status: Accepted

Solution code:

def C():
    import math
    n= int(input())

    counter = 0
    for i in range(1,13):
        if int(26*(pow(26,i-1))/(26-1)) <= n < int(26*(pow(26,i))/(26-1)):
            counter = i
            break
    kekka = n - int(26*(pow(26,counter-1))/(26-1))

    alplist=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

    kekkalist = []
    i = counter-1
    while i>= 0 :
        sho = int(kekka / pow(26,i))
        kekka = kekka - pow(26,i)*sho

        i -=1
        if i >= 0:
            kekkalist.append(alplist[sho])
        else:
            kekkalist.append(alplist[sho])


    print("".join(kekkalist))


C()

Submission status: Accepted

Solution code:
num = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
while num > 26:
    num, rest = divmod(num, 26)
    ans += s[rest - 1]
    if rest == 0:
        num -= 1
    #num -= 1
    #print(ans, num, rest)
    
ans += s[num - 1]
print(ans[::-1])

Submission status: Accepted

Solution code:
alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def ind(b,n):
    check=0
    if n==0:
        return 0
    res=1
    while n>=check:
        check+=26*(res)
        res+=1
    return res-1

N=int(input())
if 26>=N:
    print(alphabetlist[N-1])
    exit()
ans=[]
L=-1
check=0
for i in range(0,50):
    test=check+26**i
    if test>N:
        L=i
        break
    else:
        check=test
ans=[""]*L
n=N-check
for i in range(L-1,-1,-1):
    q=n//(26**i)
    ans[-i-1]=alphabetlist[q]
    n=n-q*26**i
print("".join(ans))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    alphabets = [None] + [chr(ord("a") + x) for x in range(26)]
    # 1~26:１桁
    # 27 ~ 702(26**2*"1"+26**1*"1"+ 0):2桁
    # 27 ~ 52番：aa ~ az(26+1~26)
    # 53 ~ 78番：ba ~ bz(26*"2"+"1~26")
    # 703 ~ 18278(26+26*26+26*26*26):３桁
    # 703 ~ 726: aaa ~ aaz(26**2*"1"+26*"1"+"1~26")

    #何桁か？
    cnt = 0
    m = n
    while m > 0:
        cnt += 1
        m -= 26 ** cnt
    #print(cnt)

    # 各桁がどの文字か？
    num = []
    for i in range(cnt):
        # 最初は、26で割り、次は
        y = n % (26 ** (i+1))
        #print("amari:", y, "nokori:", n)
        if y == 0:
          num += [26]
          n -= 26 ** (i+1)
        else:
          n -= y
          num += [y // (26**i)]

    #print(num)

    ans = ""
    for s in num[::-1]:
        ans += alphabets[s]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)

print(num2alpha(N))

Submission status: Accepted

Solution code:
name="zabcdefghijklmnopqrstuvwxy"
def namer(number):
    if number<=26 :
        return name[number%26]
    if name[number%26]=='z':
        return namer((number//26)-1)+name[number%26]
    return namer(number//26)+name[number%26]
    
number=int(input())
print(namer(number))

Submission status: Accepted

Solution code:
n = int(input())-1
Lowecases = list(__import__('string').ascii_lowercase)

Base = len(Lowecases)
Name = ''
while True:
    Name = Lowecases[n % Base] + Name
    n //= Base
    if n <= 0:
        break
    n -= 1

print(Name)

Submission status: Accepted

Solution code:
n = int(input())

from scipy.special import comb


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(n).lower())

Submission status: Accepted

Solution code:
import math
from typing import List, NoReturn, Tuple


def main() -> NoReturn:
    n: int = int(input())
    # 0.9615384615384616 == 25 / 26
    group: int = math.ceil(math.log(0.9615384615384616 * n + 1, 26))
    in_group_index: int = n - 1 - (26 * (26 ** (group - 1) - 1)) // 25

    alphabet_num: List[int] = []
    alphabet: str = "abcdefghijklmnopqrstuvwxyz"
    temp = in_group_index
    for i in range(group - 1, -1, -1):
        alphabet_num.append(temp // 26 ** i)
        temp %= 26 ** i
    name_chars: List[str] = [alphabet[i] for i in alphabet_num]
    print("".join(name_chars))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

D = 26
lst = []
while N > 0:
    # c = N%26
    # if c == 0:
    #     ans += 'z'
    # else:
    #     ans += chr(ord('a') + (N%26) - 1)

    lst.append(N%D)
    N //= D

# print(lst)
ans = ""
z = False
for i in range(len(lst)):
    # print(i)
    if i == len(lst)-1 and lst[i] == 0:
        break

    if lst[i] == 0:
        ans += 'z'
        while lst[i+1] == 0:
            lst[i+1] = 25
            i+=1
        lst[i+1] -= 1
    else:
        ans += chr(ord('a') - 1 + lst[i])


# for c in enulst:
#     if c == 0:
#         z=True
#     else:
#         if z:
#             ans += chr(ord('z') + 1 - c)
#         else:
#             ans += chr(ord('a') - 1 + c)

# print(lst)
# print("rev:", list(reversed(lst)))
# print(ans)
print("".join(list(reversed(ans))))

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    ans = ''
    keta = 1
    tmp = 0
    while N > 0:
        cnt = N % 26
        if cnt == 0:
            cnt = 26
            N -= 1
        ans = chr(96+cnt) + ans
        N //= 26
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
kugiri = [0,26,702,18278,475254,12356630,321272406,8353082582,217180147158,5646683826134,146813779479510,3817158266467286]
ans = ""

for i in range(len(kugiri)):
    if n <= kugiri[i]:
        keta = i
        break
        
n -= kugiri[i-1]

for i in range(keta):
    moji = -(-n // 26**(keta-1))
    ans += chr(moji+96)
    n -= (moji-1) * 26**(keta-1)
    keta -= 1
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = ""
t = 26
c = ['z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']
while n > 0:
    s += c[int(n%t)]
    n -= 1
    n //= 26
print(s[::-1])

Submission status: Accepted

Solution code:
LIMIT = 1000000000000001
alphabet = {-1: "!", 0: "a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f", 6: "g", 7:"h", 8:"i", 9:"j", 10:"k", 11:"l",
                12:"m", 13:"n", 14: "o", 15:"p", 16:"q", 17:"r", 18:"s", 19:"t", 20:"u", 21: "v",
                22: "w", 23: "x",  24: "y",  25: "z"}



N = int(input())
answer = ""
# times = 1

while True:
    N = N - 1
    a = int(N / 26)
    b = N % 26
    answer += alphabet[b]
    if a == 0: break
    N = a


print(answer[::-1])

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = []
while(N>26):
    s = N % 26
    if s == 0:
      A.append(26)
      N = (N-26) // 26
    else:
      A.append(s)
      N = (N-s) // 26
A.append(N)
A = A[::-1]
ans = ''
d = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in A:
  ans += d[i-1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
com = [0]
a = 0
v = 0
j = 0
str1 = "abcdefghijklmnopqrstuvwxyz"

if N < 27:
    print(str1[N-1])
else:
    for i in range(1,13):
        a += 26**i
        com.append(a)
    for i in range(13):
        if N < com[i]+1:
            v = com[i-1]
            j = i
            break
    N = N - v - 1
    ans = []
    for i in range(j-1,-1,-1):
        ans.append(str1[N//(26**i)])
        if N >= 26**i:
            N = N - N//(26**i) * (26**i)

    print("".join(ans))

Submission status: Accepted

Solution code:
s=int(input())-1
d=[]
while s>=0:
  d.append(chr(s%26+97))
  s//=26
  s-=1
t=''
for i in reversed(d):
  t+=i
print(t)

Submission status: Accepted

Solution code:


if __name__ == "__main__":
    n = input()
    char_string = "qazwsxedcrfvtgbyhnujmikolp"
    char_list = sorted(list(char_string))

    n = int(n)
    result_string = ""
    while 1:
        if n <= 26:
            break
        result_string = char_list[int((n%26)-1)] + result_string
        if (n % 26) == 0:
            n = n//26-1
        else:
            n = n//26
    result_string = char_list[n-1] + result_string
    print(result_string)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())


    ans = []


    while True:
        a,b = divmod(N, 26)
        if a>0 and b == 0:
            a = a-1
            b = 26
        ans.append(b)
        N = a
        if a==0:
            break
    #print(ans)
    trueans = []
    for i in ans:
        trueans.append(chr(96+i))

    print("".join(reversed(trueans)))




if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N = int(input())

alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(10**15):
  a = N
  N -= 26**i
  if N < 0:
    n = i
    break
ans = ['']*n
S = [0]*n
for i in range(n):
  S[-i-1] = (a//(26**i))%26
  ans[-i-1] = alp[S[-i-1]]

print(''.join(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N = int(input())

    ds = []
    for n in range(12):
        k = 11 - n
        threshold = sum([26 ** i for i in range(k+1)])
        d = 0
        if N >= threshold:
            for j in range(26):
                if N >= threshold + 26 ** k * j:
                    d = j
            d += 1
            N -= 26 ** k * d
        ds.append(d)

    chars = 'abcdefghijklmnopqrstuvwxyz'
    result = ''
    for n in range(12):
        if ds[n] > 0:
            result += chars[ds[n]-1]

    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    name = []
    while n > 0:
        c = n % 26
        n //= 26
        if c == 0:
            name.append('z')
            n -= 1
        else:
            name.append(chr(c + 96))

    name.reverse()
    ans = ''.join(name)
    print(ans)

resolve()

Submission status: Accepted

Solution code:
n = int(input())
n -= 1
if (n == 0):
	print('a')
else:
	ans = []
	ln = 1
	s = 0
	v = []
	while (s <= n):
		v.append(s)
		s += 26 ** ln
		ln += 1
	v.append(s)
	ln -= 1
	n -= (s - 26 ** (ln + 1))
	# print(ln, "len")
	while (ln > 0):
		ans.append(n % 26)
		n //= 26
		# # n -= v[ln - 1]
		# n -= ((26 ** (ln - 1)) * max(1, (n % 26 + 1)))
		# # n += v[ln]
		ln -= 1
	ans = ans[::-1]
	# print(ans)
	# ans[0] -= 1;
	for x in ans:
		print(chr(x + ord('a')), end = "")