結果

問題 No.254 文字列の構成
コンテスト
ユーザー fine
提出日時 2017-09-01 18:34:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 167,168 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-06 17:26:30
合計ジャッジ時間 6,968 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int hoge(int x) {
	x *= 2;
	int ok = 1, ng = 32000;
	while (ng - ok > 1) {
		int mid = (ok + ng) / 2;
		if (mid * mid <= 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 += 2) {
		int cnt = hoge(n);
		for (int j = 0; j < cnt * 2 - 1; j++) {
			ans += 'a' + (i + j % 2) % 26;
		}
		n -= cnt * cnt;
	}
	cout << ans << endl;
	return 0;
}
0