結果

問題 No.254 文字列の構成
ユーザー yosupotyosupot
提出日時 2016-07-16 13:42:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 192 ms / 5,000 ms
コード長 1,172 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 100,788 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 13:43:01
合計ジャッジ時間 4,336 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 21 ms
5,376 KB
testcase_17 AC 191 ms
5,376 KB
testcase_18 AC 192 ms
5,376 KB
testcase_19 AC 164 ms
5,376 KB
testcase_20 AC 99 ms
5,376 KB
testcase_21 AC 169 ms
5,376 KB
testcase_22 AC 44 ms
5,376 KB
testcase_23 AC 74 ms
5,376 KB
testcase_24 AC 74 ms
5,376 KB
testcase_25 AC 152 ms
5,376 KB
testcase_26 AC 147 ms
5,376 KB
testcase_27 AC 150 ms
5,376 KB
testcase_28 AC 115 ms
5,376 KB
testcase_29 AC 179 ms
5,376 KB
testcase_30 AC 168 ms
5,376 KB
testcase_31 AC 35 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

int main() {
    int N;
    cin >> N;
    string s;
    char base = 'a';
    while (N) {
        int i = 1;
        int sm = 1;
        while (true) {
            int nsm = 0;
            for (int j = 0; j <= i; j++) {
                nsm += j*2;
            }
            nsm += i+1;
            if (N < nsm) break;
            i++;
            sm = nsm;
        }
        for (int j = 0; j < i*2-1; j++) {
            if (j % 2 == 0) {
                s += base;
            } else {
                s += base+1;
            }
        }
        N -= sm;
        if (!N) break;
        N--;
        s += base+2;
        base += 3;
    }
    cout << s << endl;
//    for (int d: v) {
//        cout << d << endl;
//    }
    return 0;
}
0