結果
| 問題 |
No.1255 ハイレーツ・オブ・ボリビアン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-23 14:04:11 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 499 bytes |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 18,080 KB |
| 最終ジャッジ日時 | 2024-09-22 09:13:37 |
| 合計ジャッジ時間 | 8,513 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 TLE * 1 -- * 1 |
ソースコード
def main2(n):
if n==1:return 1
# 2^i==1 mod 2*n-1 となるiを返す
mod=2*n-1
d={0:1}
now=2
c=int(n**0.5)
for i in range(c+3):
if now==1:
return i+1
d[now]=i+1
now=now*2%mod
inv2=pow(2,-1,mod)
gs=pow(inv2,c,mod)
now=gs
cnt=1
while True:
if now in d:
# 2^(-c*cnt)=2^d[now]
# 1=2^(c*cnt+d[now])
return d[now]+c*cnt
now=now*gs%mod
cnt+=1
t=int(input())
cases=[int(input()) for _ in range(t)]
for n in cases:
print(main2(n))