結果
| 問題 |
No.254 文字列の構成
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-08-12 14:32:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 884 bytes |
| コンパイル時間 | 1,229 ms |
| コンパイル使用メモリ | 159,088 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-18 06:56:28 |
| 合計ジャッジ時間 | 6,087 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 1 WA * 29 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
ll f(ll x) {
return (x + 1) * (x + 2) / 2 - (x + 1);
}
int main() {
ll N;
cin >> N;
string ans;
for (char c = 'a'; N > 0 && c <= 'z'; c++) {
ll l = 0;
ll r = 1000000;
while (r - l > 1) {
ll m = (l + r) / 2;
if (f(m) <= N) {
l = m;
} else {
r = m;
}
}
N -= f(l);
ans += string(l, c);
}
if (N > 0) {
cout << "toro" << endl;
} else {
cout << ans << endl;
}
}