結果

問題 No.2120 場合の数の下8桁
ユーザー googol_S0googol_S0
提出日時 2022-11-04 21:49:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 555 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 76,904 KB
最終ジャッジ日時 2023-09-26 00:11:57
合計ジャッジ時間 5,549 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,156 KB
testcase_01 AC 80 ms
71,400 KB
testcase_02 AC 379 ms
75,748 KB
testcase_03 AC 241 ms
75,760 KB
testcase_04 AC 131 ms
75,532 KB
testcase_05 AC 75 ms
71,496 KB
testcase_06 AC 104 ms
75,496 KB
testcase_07 AC 76 ms
71,564 KB
testcase_08 AC 75 ms
71,356 KB
testcase_09 AC 79 ms
75,692 KB
testcase_10 AC 91 ms
75,636 KB
testcase_11 AC 353 ms
76,020 KB
testcase_12 AC 131 ms
75,708 KB
testcase_13 AC 292 ms
76,200 KB
testcase_14 AC 478 ms
76,180 KB
testcase_15 AC 229 ms
76,300 KB
testcase_16 AC 369 ms
76,304 KB
testcase_17 AC 555 ms
76,344 KB
testcase_18 AC 76 ms
71,344 KB
testcase_19 AC 308 ms
76,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M=int(input())
N=int(input())
mod=10**8
if M<N:
  print('0'*8)
  exit()
N=min(N,M-N)
c2=0
c5=0
A=1
B=1
for i in range(1,M+1):
  if i<=N:
    while i&1==0:
      i>>=1
      c2-=1
    while i%5==0:
      i//=5
      c5-=1
    B=B*i%mod
  elif M-N<i:
    while i&1==0:
      i>>=1
      c2+=1
    while i%5==0:
      i//=5
      c5+=1
    A=A*i%mod
for i in range(mod):
  if i*B%mod==1:
    B=i
    break
S=str(A*B*pow(2,c2,mod)*pow(5,c5,mod)%mod)
while len(S)<8:
  S='0'+S
print(S)
0