結果
| 問題 | 
                            No.2766 Delicious Multiply Spice
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-05-31 21:24:59 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 895 bytes | 
| コンパイル時間 | 1,056 ms | 
| コンパイル使用メモリ | 70,840 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-20 22:16:11 | 
| 合計ジャッジ時間 | 2,186 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 WA * 2 | 
| other | AC * 6 WA * 25 | 
ソースコード
#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 {
            // If none of the conditions are met, there's no valid sequence
            return "";
        }
    }
    // Reverse the recorded operations to get the correct sequence
    std::string result;
    for (auto it = operations.rbegin(); it != operations.rend(); ++it) {
        result += *it;
    }
    
    return result;
}
int main() {
    int N;
    std::cin >> N;
    std::string result = find_operations(N);
    std::cout << result << std::endl;
    return 0;
}