Submission #19545905
Source Code Expand
Copy
class Factorial: def __init__(self, max_fact, mod): #mod should be prime number #using homogeneous_product(n,r), max_fact ≧ max(n+r-1) f = [1] * (max_fact + 1) for idx in range(2, max_fact + 1): f[idx] = f[idx - 1] * idx f[idx] %= mod if mod > max_fact: fi = [pow(f[-1], mod - 2, mod)] for idx in range(max_fact, 0, -1): fi += [fi[-1] * idx % mod] fi = fi[::-1] else: fi = [pow(n, mod - 2, mod) for n in f] self.mod = mod self.f = f self.fi = fi def factorial(self, n): return self.f[n] def factorial_inverse(self, n): return self.fi[n] def combination(self, n, r): f = self.f fi = self.fi return f[n] * fi[r] * fi[n - r] % self.mod def permutation(self, n, r): return self.f[n] * self.fi[n - r] % self.mod def homogeneous_product(self, n, r): f = self.f fi = self.fi return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod d = int(input()) max_fact = 2 * d - 1 mod = 998244353 fact_instance = Factorial(max_fact, mod) comb = fact_instance.combination ans = comb(2 * d - 1, d - 1) print(ans)
Submission Info
Submission Time | |
---|---|
Task | A - Dodecagon |
User | yydoco |
Language | Python (3.8.2) |
Score | 500 |
Code Size | 1298 Byte |
Status | AC |
Exec Time | 936 ms |
Memory | 182884 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, example0.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 936 ms | 182884 KB |
001.txt | AC | 27 ms | 9216 KB |
002.txt | AC | 85 ms | 20092 KB |
003.txt | AC | 929 ms | 182808 KB |
004.txt | AC | 916 ms | 180796 KB |
005.txt | AC | 48 ms | 13392 KB |
006.txt | AC | 20 ms | 9148 KB |
007.txt | AC | 55 ms | 13612 KB |
008.txt | AC | 927 ms | 182868 KB |
009.txt | AC | 925 ms | 182704 KB |
010.txt | AC | 29 ms | 9216 KB |
example0.txt | AC | 25 ms | 9144 KB |