結果
| 問題 |
No.254 文字列の構成
|
| コンテスト | |
| ユーザー |
yosupot
|
| 提出日時 | 2016-07-16 13:42:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 183 ms / 5,000 ms |
| コード長 | 1,172 bytes |
| コンパイル時間 | 979 ms |
| コンパイル使用メモリ | 100,920 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 13:44:00 |
| 合計ジャッジ時間 | 4,274 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}
int main() {
int N;
cin >> N;
string s;
char base = 'a';
while (N) {
int i = 1;
int sm = 1;
while (true) {
int nsm = 0;
for (int j = 0; j <= i; j++) {
nsm += j*2;
}
nsm += i+1;
if (N < nsm) break;
i++;
sm = nsm;
}
for (int j = 0; j < i*2-1; j++) {
if (j % 2 == 0) {
s += base;
} else {
s += base+1;
}
}
N -= sm;
if (!N) break;
N--;
s += base+2;
base += 3;
}
cout << s << endl;
// for (int d: v) {
// cout << d << endl;
// }
return 0;
}
yosupot