結果

問題 No.254 文字列の構成
ユーザー Kiona1018Kiona1018
提出日時 2019-09-26 20:56:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,156 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 172,096 KB
実行使用メモリ 4,620 KB
最終ジャッジ日時 2023-10-24 15:47:19
合計ジャッジ時間 6,539 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,620 KB
testcase_01 WA -
testcase_02 AC 3 ms
4,620 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
const int MAXS = 100000;

vector<ll> triangle;
vector<ll> triangle_plus;
void init()
{
    triangle.assign(MAXS, 0);
    triangle_plus.assign(MAXS, 0);
    rep(i, 0, MAXS) triangle[i] = (ll)i * (i+1) / 2;
    rep(i, 0, MAXS) triangle_plus[i] = triangle[i] + i;
}

int main()
{
    init();
    ll n;
    cin >> n;

    vector<int> nums;
    vector<ll>::iterator itr = upper_bound(triangle.begin(), triangle.end(), n);
    --itr;
    nums.push_back(itr - triangle.begin());
    n -= *itr;

    while (n > 1)
    {
        vector<ll>::iterator itr_plus = upper_bound(triangle_plus.begin(), triangle_plus.end(), n);
        --itr_plus;
        // cout << itr_plus - triangle_plus.begin() << ' '  << *itr_plus << endl;
        nums.push_back(itr_plus - triangle_plus.begin());
        n -= *itr_plus;
    }
    if (n == 1)
        nums.push_back(1);

    rep(i, 0, nums.size())
    {
        rep(j, 0, nums[i])
            printf("%c", 'a' + i % 26);
    }
    cout << endl;
    return 0;
}
0