結果
| 問題 | No.254 文字列の構成 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-09-01 18:35:51 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 492 bytes | 
| コンパイル時間 | 1,752 ms | 
| コンパイル使用メモリ | 167,208 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-06 17:26:41 | 
| 合計ジャッジ時間 | 3,121 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 30 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int hoge(int x) {
	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;
}
            
            
            
        