結果
| 問題 |
No.1409 Simple Math in yukicoder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-02 13:31:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 591 bytes |
| コンパイル時間 | 189 ms |
| コンパイル使用メモリ | 82,096 KB |
| 実行使用メモリ | 284,900 KB |
| 最終ジャッジ日時 | 2024-10-03 01:43:05 |
| 合計ジャッジ時間 | 60,642 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 TLE * 12 -- * 22 |
ソースコード
from random import randint
def main(u,x):
p=x*u+1
if u==1:return list(range(1,p))
if x==1:return [x]
# p:prime
# a^(p-1)=1 mod p
# p=x*u+1
# a^(x*u)=1 mod p
# (a^u)^x=1 mod p
while True:
i=randint(2,p-1)
s={i}
ii=i*i%p
while ii!=i:
s.add(ii)
ii=ii*i%p
if len(s)==p-1:break
i=pow(i,u,p)
ary=[]
ii=i
for _ in range(x):
ary.append(ii)
ii=ii*i%p
ary.sort()
return ary
if __name__=='__main__':
t=int(input())
cases=[list(map(int,input().split())) for _ in range(t)]
for u,x in cases:
ret=main(u,x)
print(*ret)