結果

問題 No.3115 One Power One Kill
ユーザー Mistletoe
提出日時 2025-04-19 18:33:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 27,656 KB
平均クエリ数 1.00
最終ジャッジ日時 2025-04-19 18:33:13
合計ジャッジ時間 4,698 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def solve():
    # Step 1: Output A and B
    # Choose A and B strategically to get meaningful gcd results
    A = 12345  # Example value, can be adjusted
    B = 67890  # Example value, can be adjusted
    print(A, B, flush=True)  # Output A and B, and flush output

    # Step 2: Receive K from the judge
    K = int(input())  # Judge provides K = gcd(X, Y)

    # Step 3: Use K to narrow down possible X values
    possible_X = []
    for i in range(1, 10**5 // K + 1):  # Enumerate multiples of K
        X = K * i
        if 100 <= X <= 10**5:  # Ensure X is within the valid range
            possible_X.append(X)

    # Step 4: Compute X' for each possible X and guess
    for X in possible_X:
        # Calculate X' = X^A mod B
        X_prime = pow(X, A, B)  # Use Python's built-in pow with three arguments
        print(X_prime, flush=True)  # Output the guess for X' and flush

        # Step 5: Receive the judge's response (ret)
        ret = int(input())  # Judge responds with 1 if correct, 0 otherwise
        if ret == 1:
            return  # Correct guess, exit the function
0