結果

問題 No.2766 Delicious Multiply Spice
ユーザー Kei
提出日時 2024-05-31 21:41:52
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 402 bytes
コンパイル時間 5,852 ms
コンパイル使用メモリ 275,636 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-20 22:56:37
合計ジャッジ時間 5,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
void f(long long N, string &S) {
  if (N == 1) {
    reverse(S.begin(), S.end());
    cout << S << endl;
    exit(0);
  }
  N--;
  if (N % 2 == 0) {
    S.push_back('A');
    f(N / 2, S);
    S.pop_back();
  }
  if (N % 3 == 0) {
    S.push_back('B');
    f(N / 3, S);
    S.pop_back();
  }
}
int main() {
  long long N;
  cin >> N;
  string S;
  f(N, S);
}
0