結果

問題 No.1409 Simple Math in yukicoder
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-03-02 14:06:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 78,232 KB
最終ジャッジ日時 2024-04-14 04:37:26
合計ジャッジ時間 32,661 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,872 KB
testcase_01 AC 42 ms
54,308 KB
testcase_02 AC 43 ms
54,676 KB
testcase_03 AC 42 ms
54,316 KB
testcase_04 AC 42 ms
56,116 KB
testcase_05 AC 42 ms
54,712 KB
testcase_06 AC 42 ms
54,568 KB
testcase_07 AC 71 ms
72,628 KB
testcase_08 AC 110 ms
77,172 KB
testcase_09 AC 71 ms
72,832 KB
testcase_10 AC 101 ms
77,416 KB
testcase_11 AC 110 ms
77,440 KB
testcase_12 AC 99 ms
77,412 KB
testcase_13 AC 75 ms
73,228 KB
testcase_14 AC 66 ms
71,024 KB
testcase_15 AC 86 ms
77,280 KB
testcase_16 AC 77 ms
74,744 KB
testcase_17 AC 122 ms
77,832 KB
testcase_18 AC 93 ms
77,184 KB
testcase_19 AC 98 ms
77,276 KB
testcase_20 AC 95 ms
77,296 KB
testcase_21 AC 88 ms
77,164 KB
testcase_22 AC 102 ms
77,480 KB
testcase_23 AC 66 ms
70,000 KB
testcase_24 AC 61 ms
68,200 KB
testcase_25 AC 105 ms
77,296 KB
testcase_26 AC 104 ms
77,692 KB
testcase_27 AC 128 ms
77,972 KB
testcase_28 AC 128 ms
77,584 KB
testcase_29 AC 129 ms
78,232 KB
testcase_30 AC 130 ms
77,800 KB
testcase_31 AC 130 ms
77,556 KB
testcase_32 AC 128 ms
77,996 KB
testcase_33 AC 132 ms
77,568 KB
testcase_34 AC 128 ms
78,004 KB
testcase_35 AC 131 ms
77,664 KB
testcase_36 AC 129 ms
78,232 KB
testcase_37 AC 145 ms
77,684 KB
testcase_38 AC 147 ms
77,832 KB
testcase_39 AC 144 ms
77,692 KB
testcase_40 AC 145 ms
77,704 KB
testcase_41 AC 144 ms
77,796 KB
testcase_42 AC 145 ms
77,764 KB
testcase_43 AC 145 ms
77,584 KB
testcase_44 AC 146 ms
77,708 KB
testcase_45 AC 151 ms
77,624 KB
testcase_46 AC 146 ms
77,552 KB
testcase_47 AC 146 ms
77,668 KB
testcase_48 AC 146 ms
77,800 KB
testcase_49 AC 144 ms
77,748 KB
testcase_50 AC 145 ms
77,720 KB
testcase_51 AC 149 ms
77,916 KB
testcase_52 AC 149 ms
77,768 KB
testcase_53 AC 145 ms
77,672 KB
testcase_54 AC 148 ms
77,656 KB
testcase_55 AC 144 ms
77,984 KB
testcase_56 AC 144 ms
77,556 KB
testcase_57 AC 151 ms
77,612 KB
testcase_58 AC 151 ms
77,808 KB
testcase_59 AC 152 ms
77,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(n):
  s=set()
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      s.add(i)
      s.add(n//i)
  return s

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
  ss=func(p-1)
  f=p-1-len(ss)
  while True:
    i=randint(2,p-2)
    s={i}
    flg=True
    for xx in ss:
      if pow(i,xx,p)!=1:
        continue
      else:
        flg=False
        break
    if flg: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)
0