結果

問題 No.254 文字列の構成
ユーザー fine
提出日時 2017-09-01 18:24:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 470 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 166,748 KB
実行使用メモリ 108,548 KB
最終ジャッジ日時 2024-11-06 17:26:23
合計ジャッジ時間 10,430 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 1 WA * 14 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int hoge(int x) {
	x *= 2;
	int ok = 1, ng = 50000;
	while (ng - ok > 1) {
		int mid = (ok + ng) / 2;
		if (mid * (mid + 1) <= x) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string ans = "";
	for (int i = 0; n > 0 ; i++) {
		int cnt = hoge(n);
		ans += string(cnt, 'a' + i % 26);
		n -= cnt * (cnt + 1) / 2;
	}
	cout << ans << endl;
	return 0;
}
0