結果

問題 No.327 アルファベット列
ユーザー zn_kie
提出日時 2019-07-15 09:19:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 67,588 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 07:19:09
合計ジャッジ時間 1,855 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

    // 1桁目だけ 0:A ... 25:Z
    // それ以降は 1:A ... 26:Z
    char tmp = 'A'+N_%26;
    ans += tmp;
    N_ /= 26;
    while(N_){
        N_--;
        int s = N_ % 26;
        tmp = 'A' + s;
        ans += tmp;
        N_ /= 26;
    }
    // 後ろに加えていくので最後に文字順を逆転する
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}
0