結果

問題 No.2120 場合の数の下8桁
ユーザー flygonflygon
提出日時 2022-11-04 23:03:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 762 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 251,480 KB
最終ジャッジ日時 2023-09-26 01:33:29
合計ジャッジ時間 6,913 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,288 KB
testcase_01 AC 71 ms
71,272 KB
testcase_02 AC 71 ms
71,488 KB
testcase_03 AC 74 ms
71,220 KB
testcase_04 AC 70 ms
71,236 KB
testcase_05 AC 70 ms
71,628 KB
testcase_06 AC 762 ms
251,312 KB
testcase_07 AC 71 ms
71,380 KB
testcase_08 AC 71 ms
71,176 KB
testcase_09 AC 86 ms
77,688 KB
testcase_10 AC 377 ms
169,068 KB
testcase_11 AC 731 ms
251,412 KB
testcase_12 AC 79 ms
76,284 KB
testcase_13 AC 86 ms
77,792 KB
testcase_14 AC 91 ms
80,224 KB
testcase_15 AC 380 ms
167,976 KB
testcase_16 AC 696 ms
243,228 KB
testcase_17 AC 738 ms
248,344 KB
testcase_18 AC 69 ms
71,276 KB
testcase_19 AC 757 ms
251,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

m = int(input())
n = int(input())
if n > m:
  print("0"*8)
  exit()
mod = 10**8

def e(n): #O(NloglogN)
  l = [i for i in range(n+1)]
  x = []
  for i in range(2,n+1):
    if l[i] == i:
      x.append(i)
      for p in range(i+i,n+1,i):
        l[p] = i
  return x

p = e(m)
d =[0]*(m+1)
for pn in p:
  now = pn
  cnt = 0
  while now <= m:
    cnt += m//now-(m-n)//now
    cnt -= n//now
    now *= pn
  d[pn] = cnt
ans = 1
for k,v in enumerate(d):
  if v == 0: continue
  ans *= pow(k,v,mod)
  ans %= mod

ans = str(ans)
print("0"*(8-len(ans)) + ans)



  
0