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

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

string alphabet = "abcdefghijklmnopqrstuvwxyz";

int main()
{
    ll N;
    cin >> N;
    ll l = 0;
    string ans = "";

    while (true)
    {
        ans.append("a");
        l++;

        if (pow(26, l) >= N)
        {
            break;
        }
    }

    ll M = 0;
    for (ll i = 1; i < l; i++)
    {
        M += pow(26, i);
    }

    // kth num in l digit base-26
    ll k = N - M;
    rep(i, l)
    {
        if (i == l - 1)
        {
            ans[l - 1] = alphabet[k - 1];
        }
        else
        {
            ll d = pow(26, l - 1 - i);
            ll q = k / d;
            ans[i] = alphabet[q];
            k -= d * q;
        }

        if (k == 0)
        {
            break;
        }
    }

    cout << ans << endl;
}