結果

問題 No.600 かい文回
ユーザー pekempeypekempey
提出日時 2017-11-27 12:30:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 586 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 71,660 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-05 13:14:40
合計ジャッジ時間 4,279 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,704 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

char pt0 = 'p';
char pt1 = 'q';

void step() {
  pt1++;
  if (pt1 > 'z') {
    pt0++;
    pt1 = pt0 + 1;
  }
}

string foo() {
  string ret;
  ret += pt0;
  ret += pt1;
  return ret;
}

string bar() {
  string ret;
  ret += pt0;
  ret += pt1;
  step();
  return ret;
}

string solve(int n) {
  if (n == 1) return bar();
  if (n % 2 == 0) foo() + solve(n / 2) + foo();
  string t = bar();
  return t + solve(n - 1) + t;
}

int main() {
  int n;
  cin >> n;
  cout << solve(n) << endl;
}
0