結果

問題 No.3115 One Power One Kill
ユーザー Mistletoe
提出日時 2025-04-19 11:54:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,672 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 86,340 KB
実行使用メモリ 26,380 KB
平均クエリ数 3.00
最終ジャッジ日時 2025-04-19 11:54:50
合計ジャッジ時間 5,570 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <algorithm>

const int MOD = 1e9 + 7;

// Function to compute (base^exp) % mod using binary exponentiation
long long modExp(long long base, long long exp, long long mod) {
    long long result = 1;
    while (exp > 0) {
        if (exp % 2 == 1) {
            result = (result * base) % mod;
        }
        base = (base * base) % mod;
        exp /= 2;
    }
    return result;
}

int main() {
    // Step 1: Choose A and B. A simple approach would be trying small values for A and B first.
    int A = 100;  // Experiment with this value.
    int B = 100;  // Experiment with this value.

    // Output A and B
    std::cout << A << " " << B << std::endl;
    std::flush(std::cout);  // Ensure the output is flushed

    // Step 2: Calculate Y = A^B % (10^9 + 7)
    long long Y = modExp(A, B, MOD);

    // Step 3: Read the value of K from the judge (GCD of X and Y)
    int K;
    std::cin >> K;

    // Step 4: Now we need to guess X'. We don't know X, so we need a strategy.
    // A good first guess could be X' = K, but we need to make an informed guess based on K.
    int X_prime_guess = K;  // Start with the guess based on K.

    // Output the guess for X'
    std::cout << X_prime_guess << std::endl;
    std::flush(std::cout);  // Ensure the output is flushed

    // Step 5: Read the result from the judge (ret = 1 if correct, 0 if incorrect)
    int ret;
    std::cin >> ret;

    // If ret == 1, the guess is correct; otherwise, it's incorrect
    if (ret == 1) {
        std::cout << "Correct guess!" << std::endl;
    } else {
        std::cout << "Incorrect guess!" << std::endl;
    }

    return 0;
}
0