結果

問題 No.327 アルファベット列
ユーザー rabimea
提出日時 2025-09-26 05:16:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 2,930 ms
コンパイル使用メモリ 276,328 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-26 05:16:13
合計ジャッジ時間 5,411 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>

using std::cin, std::cout, std::cerr;
using ll = long long;

ll Pow(ll a, ll b) {
    ll r = 1;
    while(b) {
        r *= a;
        b --;
    }
    return r;
}

int main() {
    std::ios::sync_with_stdio(false);
    ll n; cin >> n;
    std::string s = "";
    int d = 1;
    while(n >= Pow(26, d)) {
        n -= Pow(26, d);
        d ++;
    }
    
    for(int i = d - 1; i >= 0; i --) {
        char c = 'A';
        while(n >= Pow(26, i)) {
            n -= Pow(26, i);
            c ++;
        }
        s += c;
    }
    cout << s << '\n';
}
0