結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
27,480 KB
testcase_01 AC 42 ms
27,224 KB
testcase_02 AC 52 ms
27,352 KB
testcase_03 AC 199 ms
27,480 KB
testcase_04 AC 261 ms
27,352 KB
testcase_05 WA -
testcase_06 AC 247 ms
27,224 KB
testcase_07 AC 250 ms
27,992 KB
testcase_08 WA -
testcase_09 AC 188 ms
27,224 KB
testcase_10 AC 42 ms
27,352 KB
testcase_11 AC 67 ms
27,352 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 51 ms
27,480 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 259 ms
27,600 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 334 ms
27,352 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 241 ms
27,736 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 207 ms
27,352 KB
testcase_28 AC 243 ms
27,608 KB
testcase_29 AC 190 ms
27,608 KB
権限があれば一括ダウンロードができます

ソースコード

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)
Answer(1)
0