結果

問題 No.254 文字列の構成
ユーザー 🍮かんプリン
提出日時 2020-05-25 01:09:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 946 bytes
コンパイル時間 1,498 ms
コンパイル使用メモリ 159,572 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 16:00:16
合計ジャッジ時間 5,217 ms
ジャッジサーバーID
(参考情報)
judge / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.25 01:08:55
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    ll k = 0;
    while((k + 1) * (k + 6) / 2 + 1 <= n) {
        k++;
    }
    string s;
    ll cnt = k * (k + 5) / 2 + 1;
    for (int i = 0; i < k; i++) {
        s += "ab";
    }
    s += "a";
    ll k2 = 0;
    while((k2 + 1) * (k2 + 6) / 2 + 1 <= n - cnt) {
        k2++;
    }
    if (cnt == n) {
        cout << s << endl;
        return 0;
    }
    ll cnt2 = k2 * (k2 + 5) / 2 + 1;
    for (int i = 0; i < k2; i++) {
        s += "cd";
    }
    s += "c";
    for (ll i = cnt + cnt2; i < n; i++) {
        s += "e";
        i++;
        if (i < n) {
            s += "f";
            i++;
        }
        if (i < n) {
            s += "g";
            i++;
        }
    }
    //cout << s.size() << endl;
    cout << s << endl;
    return 0;
}
0