結果

問題 No.254 文字列の構成
ユーザー pekempey
提出日時 2015-08-12 14:48:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,091 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 159,340 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 06:56:31
合計ジャッジ時間 2,467 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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) {
if (x % 2 == 0) {
return (x + 0) * (x / 2 + 1) / 2;
} else {
return (x + 1) * (x / 2 + 1) / 2;
}
}
int main() {
ll N;
cin >> N;
string ans;
for (char c = 'a'; N > 0 && c <= 'z'; c += 2) {
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);
rep (i, l) {
if (i % 2 == 0) {
ans += c;
} else {
ans += c + 1;
}
}
}
if (N > 0) {
cout << "toro" << endl;
} else {
cout << ans << endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0