結果

問題 No.3093 Please GCD
ユーザー nasubi24nasubi24
提出日時 2022-04-01 22:48:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 82,552 KB
実行使用メモリ 94,572 KB
平均クエリ数 574.30
最終ジャッジ日時 2024-04-30 15:10:59
合計ジャッジ時間 11,419 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
93,404 KB
testcase_01 AC 140 ms
93,408 KB
testcase_02 AC 151 ms
94,308 KB
testcase_03 AC 251 ms
93,744 KB
testcase_04 AC 233 ms
90,264 KB
testcase_05 WA -
testcase_06 AC 221 ms
89,420 KB
testcase_07 AC 221 ms
89,656 KB
testcase_08 AC 302 ms
94,096 KB
testcase_09 AC 239 ms
93,828 KB
testcase_10 AC 136 ms
93,792 KB
testcase_11 AC 160 ms
94,036 KB
testcase_12 AC 203 ms
89,100 KB
testcase_13 AC 226 ms
88,696 KB
testcase_14 WA -
testcase_15 AC 150 ms
93,756 KB
testcase_16 AC 221 ms
90,112 KB
testcase_17 AC 242 ms
89,368 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 260 ms
93,632 KB
testcase_22 AC 247 ms
91,412 KB
testcase_23 AC 248 ms
93,336 KB
testcase_24 AC 263 ms
94,216 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 277 ms
94,040 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import random
n=int(input())
p=[]
for i in range(2,n+1):
    for j in range(2,i):
        if i%j==0:
            break
    else:
        p.append(i)
now=0
num=1
num2=1
cnt=0
while now!=len(p) and cnt<=450:
    tem=1
    while now!=len(p):
        if tem*p[now]>n:
            break
        tem*=p[now]
        now+=1
    cnt+=1
    print("?",tem,flush=True)
    k=int(input())
    num*=k
    num2*=tem//k
ans=num
num3=1
for i in range(600-cnt):
    cnt2=0
    while cnt2<=100:
        num3=random.randint(1,n//num)
        if math.gcd(ans//num,num3)!=num3 and math.gcd(num2,num3)==1 and num3!=1:
            break
        cnt2+=1
    if math.gcd(num2,num3)==1:
        print("?",num*num3,flush=True)
        ans=max(ans,int(input()))
print("!",ans,flush=True)
0