結果

問題 No.2766 Delicious Multiply Spice
ユーザー ANKUR PALANKUR PAL
提出日時 2024-05-31 21:30:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 891 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 70,768 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-20 22:30:29
合計ジャッジ時間 2,056 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6 WA * 2
other AC * 6 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <string>
std::string find_operations(int N) {
std::vector<char> operations;
while (N > 1) {
if ((N - 1) % 3 == 0 && (N - 1) / 3 >= 1) {
operations.push_back('B');
N = (N - 1) / 3;
} else if ((N - 1) % 2 == 0 && (N - 1) / 2 >= 1) {
operations.push_back('A');
N = (N - 1) / 2;
} else {
// This branch should not be reached due to the problem constraints
// N must be reachable from 1 using the operations
return "";
}
}
// Reverse the recorded operations to get the correct sequence
std::string result(operations.rbegin(), operations.rend());
return result;
}
int main() {
int N;
std::cin >> N;
std::string result = find_operations(N);
std::cout << result << std::endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0