結果

問題 No.2357 Guess the Function
ユーザー 👑 rin204rin204
提出日時 2024-04-14 21:11:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 1,000 ms
コード長 1,088 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 77,012 KB
平均クエリ数 3.00
最終ジャッジ日時 2024-04-14 21:11:04
合計ジャッジ時間 2,090 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
70,260 KB
testcase_01 AC 59 ms
69,116 KB
testcase_02 AC 59 ms
69,588 KB
testcase_03 AC 61 ms
75,552 KB
testcase_04 AC 60 ms
75,052 KB
testcase_05 AC 57 ms
69,372 KB
testcase_06 AC 61 ms
76,008 KB
testcase_07 AC 82 ms
77,012 KB
testcase_08 AC 81 ms
70,304 KB
testcase_09 AC 62 ms
74,828 KB
testcase_10 AC 66 ms
76,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

DEBUG = False


def solve(a=-1, b=-1):
    def ask(x):
        if DEBUG:
            return (a + x) % b
        else:
            print(f"? {x}", flush=True)
            return int(input())

    r = ask(100)
    for x in range(1, 100):
        se = set()
        ok = True
        for bb in range(1, 101):
            if r >= bb:
                continue
            aa = (r - 100) % bb
            yy = (aa + x) % bb
            if yy not in se:
                se.add(yy)
            else:
                ok = False
                break

        if ok:
            r2 = ask(x)

            for aa in range(100):
                for bb in range(aa + 1, 101):
                    if (aa + 100) % bb == r and (aa + x) % bb == r2:
                        if DEBUG:
                            assert (aa, bb) == (a, b)
                        else:
                            print(f"! {aa} {bb}")
                        return
            assert False

    assert False


if DEBUG:
    for a in range(100):
        for b in range(a + 1, 101):
            solve(a, b)
else:
    solve()
0