結果
問題 |
No.254 文字列の構成
|
ユーザー |
|
提出日時 | 2015-10-14 23:33:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 586 bytes |
コンパイル時間 | 596 ms |
コンパイル使用メモリ | 62,848 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-21 15:58:00 |
合計ジャッジ時間 | 4,970 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 1 WA * 29 |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <string> #include <iterator> using namespace std; const int LIMIT = 5e4; int main() { int n; cin >> n; vector<long long> counts(LIMIT, 0); for (long long i = 0; i < counts.size(); i++) { counts[i] = i * (i + 1) / 2; } string ans; int c_idx = 0; while (n > 0) { auto it = upper_bound(counts.begin(), counts.end(), n); it--; ans.append(distance(counts.begin(), it), 'a' + c_idx); n -= *it; c_idx = (c_idx + 1) % 26; } cout << ans << endl; return 0; }