Submission #1758824
Source Code Expand
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)
MOD = 1777777777
# 4近傍(右, 下, 左, 上)
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
# O(r)
def nCr(n, r, mod):
a, b = 1, 1
for i in range(r):
a = (a * (n - i)) % mod
b = (b * (i + 1)) % mod
return (a * pow(b, mod - 2, mod)) % mod
# モンモール数
def montmort_number(n, mod):
assert n > 1
dp = [None] * (n + 10)
dp[2] = 1
dp[3] = 2
for i in range(4, n + 1):
dp[i] = ((i - 1) * (dp[i - 1] + dp[i - 2])) % mod
return dp[n]
def main():
N, K = map(int, input().split())
a = nCr(N, K, MOD)
b = montmort_number(K, MOD)
print((a * b) % MOD)
if __name__ == '__main__':
main()
Submission Info
Submission Time
2017-11-11 16:57:40+0900
Task
C - 高橋君、24歳
User
MitI_7
Language
Python (3.4.3)
Score
100
Code Size
1090 Byte
Status
AC
Exec Time
403 ms
Memory
22124 KB
Judge Result
Set Name
small
large
Score / Max Score
40 / 40
60 / 60
Status
Set Name
Test Cases
small
00_small/small_00_sample1.txt, 00_small/small_00_sample2.txt, 00_small/small_00_sample3.txt, 00_small/small_00_sample4.txt, 00_small/small_01_rand_01.txt, 00_small/small_01_rand_02.txt, 00_small/small_01_rand_03.txt, 00_small/small_01_rand_05.txt, 00_small/small_01_rand_07.txt, 00_small/small_01_rand_08.txt, 00_small/small_01_rand_09.txt, 00_small/small_01_rand_10.txt, 00_small/small_01_rand_13.txt, 00_small/small_01_rand_14.txt, 00_small/small_01_rand_18.txt
large
00_small/small_00_sample1.txt, 00_small/small_00_sample2.txt, 00_small/small_00_sample3.txt, 00_small/small_00_sample4.txt, 00_small/small_01_rand_01.txt, 00_small/small_01_rand_02.txt, 00_small/small_01_rand_03.txt, 00_small/small_01_rand_05.txt, 00_small/small_01_rand_07.txt, 00_small/small_01_rand_08.txt, 00_small/small_01_rand_09.txt, 00_small/small_01_rand_10.txt, 00_small/small_01_rand_13.txt, 00_small/small_01_rand_14.txt, 00_small/small_01_rand_18.txt, 01_large/large_00_sample5.txt, 01_large/large_01_rand_01.txt, 01_large/large_01_rand_02.txt, 01_large/large_01_rand_03.txt, 01_large/large_01_rand_05.txt, 01_large/large_01_rand_07.txt, 01_large/large_01_rand_08.txt, 01_large/large_01_rand_09.txt, 01_large/large_01_rand_10.txt, 01_large/large_01_rand_13.txt, 01_large/large_01_rand_14.txt, 01_large/large_01_rand_18.txt
Case Name
Status
Exec Time
Memory
00_small/small_00_sample1.txt
AC
25 ms
3820 KB
00_small/small_00_sample2.txt
AC
25 ms
3820 KB
00_small/small_00_sample3.txt
AC
25 ms
3820 KB
00_small/small_00_sample4.txt
AC
25 ms
3824 KB
00_small/small_01_rand_01.txt
AC
25 ms
3820 KB
00_small/small_01_rand_02.txt
AC
25 ms
3820 KB
00_small/small_01_rand_03.txt
AC
25 ms
3820 KB
00_small/small_01_rand_05.txt
AC
24 ms
3824 KB
00_small/small_01_rand_07.txt
AC
25 ms
3824 KB
00_small/small_01_rand_08.txt
AC
25 ms
3824 KB
00_small/small_01_rand_09.txt
AC
25 ms
3824 KB
00_small/small_01_rand_10.txt
AC
25 ms
3824 KB
00_small/small_01_rand_13.txt
AC
25 ms
3824 KB
00_small/small_01_rand_14.txt
AC
25 ms
3820 KB
00_small/small_01_rand_18.txt
AC
25 ms
3820 KB
01_large/large_00_sample5.txt
AC
25 ms
3820 KB
01_large/large_01_rand_01.txt
AC
171 ms
10816 KB
01_large/large_01_rand_02.txt
AC
316 ms
17824 KB
01_large/large_01_rand_03.txt
AC
136 ms
8960 KB
01_large/large_01_rand_05.txt
AC
395 ms
21760 KB
01_large/large_01_rand_07.txt
AC
32 ms
3932 KB
01_large/large_01_rand_08.txt
AC
60 ms
5412 KB
01_large/large_01_rand_09.txt
AC
244 ms
14380 KB
01_large/large_01_rand_10.txt
AC
74 ms
6028 KB
01_large/large_01_rand_13.txt
AC
403 ms
22124 KB
01_large/large_01_rand_14.txt
AC
202 ms
12292 KB
01_large/large_01_rand_18.txt
AC
358 ms
19908 KB