結果
| 問題 |
No.2551 2, 3, 5, 7 Game
|
| コンテスト | |
| ユーザー |
Seed57_cash
|
| 提出日時 | 2023-11-21 20:30:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,384 bytes |
| コンパイル時間 | 313 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 291,404 KB |
| 最終ジャッジ日時 | 2024-09-26 07:19:19 |
| 合計ジャッジ時間 | 9,759 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 TLE * 1 -- * 4 |
ソースコード
from heapq import heappop, heappush
def solve(t, n_list):
reduce_dict = {
2: -1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,
10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: -1
}
h = []
for n in n_list:
heappush(h, -n)
while len(h):
p = heappop(h)
p *= -1
if p in reduce_dict.keys():
continue
else:
reduce_dict[p] = 0
for d in [2, 3, 5, 7]:
q = (p + d - 1) // d
if q in reduce_dict.keys():
continue
else:
heappush(h, -q)
# print(len(reduce_dict))
for p in sorted(reduce_dict.keys()):
if reduce_dict[p] != 0:
continue
r = -1
for d in [2, 3, 5, 7]:
q = (p + d - 1) // d
if reduce_dict[q] == -1:
r = 1
reduce_dict[p] = r
# for p in sorted(reduce_dict.keys()):
# print(p, reduce_dict[p])
res = []
for n in n_list:
if reduce_dict[n] == 1:
res.append("sepa")
else:
res.append("ryota")
return res
def main():
t = int(input())
n_list = [int(input()) for _ in range(t)]
res = solve(t, n_list)
for r in res:
print(r)
def test():
assert solve(3, [11, 2, 2357]) == ["sepa", "ryota", "sepa"]
if __name__ == "__main__":
test()
main()
Seed57_cash