結果

問題 No.254 文字列の構成
コンテスト
ユーザー koyumeishi
提出日時 2015-07-25 00:44:03
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 660 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 479 ms
コンパイル使用メモリ 97,040 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-30 18:32:30
合計ジャッジ時間 3,811 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

int main(){
	int n;
	cin >> n;

	long long lb = 0;
	long long ub = 100000;
	while(ub-lb > 1){
		long long mid = (lb+ub)/2;
		if( n - (mid-1)*(mid-1)/4 > 50000){
			lb = mid;
		}else{
			ub  =mid;
		}
	}

	long long ababababa = lb;
	string ans = "";
	for(int i=0; i<ababababa; i++){
		ans.push_back(i?'a':'b');
	}
	long long rem = n - (ababababa-1)*(ababababa-1)/4;
	for(int i=0; i<rem; i++){
		ans.push_back('c' + i%20);
	}

	cout << ans << endl;

	return 0;
}
0