結果
問題 | No.2120 場合の数の下8桁 |
ユーザー | Shirotsume |
提出日時 | 2022-11-04 22:12:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,669 ms / 2,000 ms |
コード長 | 1,024 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 87,000 KB |
実行使用メモリ | 241,176 KB |
最終ジャッジ日時 | 2023-09-26 00:39:43 |
合計ジャッジ時間 | 21,916 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 884 ms
201,776 KB |
testcase_01 | AC | 886 ms
201,556 KB |
testcase_02 | AC | 882 ms
201,756 KB |
testcase_03 | AC | 875 ms
201,620 KB |
testcase_04 | AC | 912 ms
201,764 KB |
testcase_05 | AC | 876 ms
201,960 KB |
testcase_06 | AC | 952 ms
241,176 KB |
testcase_07 | AC | 882 ms
201,924 KB |
testcase_08 | AC | 868 ms
202,028 KB |
testcase_09 | AC | 883 ms
202,324 KB |
testcase_10 | AC | 903 ms
240,244 KB |
testcase_11 | AC | 947 ms
241,064 KB |
testcase_12 | AC | 873 ms
201,920 KB |
testcase_13 | AC | 886 ms
202,796 KB |
testcase_14 | AC | 874 ms
203,860 KB |
testcase_15 | AC | 1,178 ms
239,492 KB |
testcase_16 | AC | 985 ms
237,116 KB |
testcase_17 | AC | 1,666 ms
240,028 KB |
testcase_18 | AC | 911 ms
201,892 KB |
testcase_19 | AC | 1,669 ms
241,168 KB |
ソースコード
import sys input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 10 ** 8 table = [True] * (10 ** 7 + 10) table[0] = table[1] = False for i in range(2, 10 ** 7 + 5): if table[i]: for j in range(2 * i, 10 ** 7 + 5, i): table[j] = False p = [] for i in range(2, 10 ** 7 + 5): if table[i]: p.append(i) def choose(n, r): if n < 0 or r < 0 or n < r: return 0 if r > n // 2: r = n - r a = [n - i for i in range(n)] for i in range(r, n): a[i] = 0 for v in p: if v > r: break q = v while q <= r: m = n % q i = m for j in range(r // q): a[i] //= v i += q q *= v mul = 1 for i in range(r): mul = mul * a[i] % mod return mul m = ii() n = ii() ans = str(choose(m, n)) ans = '0' * (8 - len(ans)) + ans print(ans)