結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 53 ms
27,128 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 214 ms
27,480 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 219 ms
27,232 KB
testcase_10 AC 52 ms
27,096 KB
testcase_11 WA -
testcase_12 AC 192 ms
27,096 KB
testcase_13 WA -
testcase_14 AC 215 ms
27,096 KB
testcase_15 AC 61 ms
27,224 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 283 ms
27,608 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 218 ms
27,736 KB
testcase_29 AC 258 ms
27,352 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]:
        Answer(i)
0