結果
| 問題 |
No.254 文字列の構成
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-02 00:14:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 547 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 60,284 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 13:20:13 |
| 合計ジャッジ時間 | 1,934 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
ll foo(ll n) { return n*(n+1)/2 - (n/2)*((n+1)/2); } // parens are important
int main() {
ll n; cin >> n;
vector<int> ans;
while (n > 0) {
ll i = 1;
while (foo(i+1) <= n) ++ i;
ans.push_back(i);
n -= foo(i);
}
repeat (i,ans.size()) {
repeat (j,ans[i]) {
cout << char((i%13)*2+(j%2) + 'a');
}
}
cout << endl;
return 0;
}