結果

問題 No.3093 Please GCD
ユーザー tnodinotnodino
提出日時 2022-04-01 21:47:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 572 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 27,992 KB
平均クエリ数 1005.97
最終ジャッジ日時 2024-04-30 13:38:46
合計ジャッジ時間 9,916 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
27,480 KB
testcase_01 AC 51 ms
26,968 KB
testcase_02 AC 57 ms
27,472 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 44 ms
26,968 KB
testcase_11 AC 71 ms
27,224 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 52 ms
26,968 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def Question(x):
    print(f'? {x}')
    return int(input())

def Answer(x):
    print(f'! {x}')
    exit()

N = int(input())
S = []
for i in range(2,N+1):
    flg = True
    for k in S:
        if i % k == 0:
            flg = False
            break
    if flg:
        S.append(i)
P = [1] * (N+1)
for i in S:
    if Question(i) >= 2:
        for j in range(2,N+1):
            if j % i != 0:
                P[j] = 0
    else:
        for j in range(i,N+1,i):
            P[j] = 0
for i in range(N,-1,-1):
    if P[i]:
        if Question(i) == i:
            Answer(i)
0