結果

問題 No.1187 皇帝ペンギン
ユーザー lemondo
提出日時 2020-08-22 14:50:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 707 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,572 KB
実行使用メモリ 91,296 KB
最終ジャッジ日時 2024-07-17 06:22:07
合計ジャッジ時間 4,655 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 53
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

s = set()
primes = []
for i in range(2, 1001):
    if i in s:
        continue
    primes.append(i)
    cnt = 2
    while cnt*i<1001:
        s.add(cnt*i)
        cnt += 1
leng = len(primes)
l, r = 0, leng
cnt = 0
while l+1<r:
    half = (l+r)//2
    print('? {}'.format(primes[half]))
    cnt += 1
    answer = input()
    if answer=='safe':
        l = half
    else:
        r = half

right = primes[l+1]
for _ in range(cnt, 25):
    print('? {}'.format(right-1))
    if input()=='safe':
        break
    else:
        right -= 1
print('! {}'.format(right-1))
exit()
0