結果

問題 No.741 AscNumber(Easy)
ユーザー shotoyooshotoyoo
提出日時 2021-05-25 23:40:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 82,432 KB
最終ジャッジ日時 2024-04-22 15:22:22
合計ジャッジ時間 4,635 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,968 KB
testcase_01 AC 35 ms
52,352 KB
testcase_02 AC 37 ms
51,712 KB
testcase_03 AC 35 ms
51,712 KB
testcase_04 AC 36 ms
52,480 KB
testcase_05 AC 36 ms
52,352 KB
testcase_06 AC 36 ms
52,224 KB
testcase_07 AC 36 ms
52,096 KB
testcase_08 AC 36 ms
51,712 KB
testcase_09 AC 37 ms
52,608 KB
testcase_10 AC 35 ms
52,224 KB
testcase_11 AC 36 ms
51,968 KB
testcase_12 AC 36 ms
51,712 KB
testcase_13 AC 36 ms
52,480 KB
testcase_14 AC 36 ms
51,968 KB
testcase_15 AC 37 ms
51,712 KB
testcase_16 AC 36 ms
52,352 KB
testcase_17 AC 37 ms
52,224 KB
testcase_18 AC 37 ms
52,368 KB
testcase_19 AC 37 ms
52,352 KB
testcase_20 AC 38 ms
51,840 KB
testcase_21 AC 38 ms
51,968 KB
testcase_22 AC 37 ms
52,096 KB
testcase_23 AC 38 ms
52,608 KB
testcase_24 AC 36 ms
52,224 KB
testcase_25 AC 37 ms
51,840 KB
testcase_26 AC 37 ms
52,736 KB
testcase_27 AC 37 ms
52,352 KB
testcase_28 AC 37 ms
52,584 KB
testcase_29 AC 37 ms
52,224 KB
testcase_30 AC 36 ms
52,224 KB
testcase_31 AC 37 ms
52,224 KB
testcase_32 AC 38 ms
52,352 KB
testcase_33 AC 38 ms
52,352 KB
testcase_34 AC 38 ms
52,224 KB
testcase_35 AC 92 ms
81,280 KB
testcase_36 AC 64 ms
68,608 KB
testcase_37 AC 67 ms
69,888 KB
testcase_38 AC 68 ms
69,888 KB
testcase_39 AC 65 ms
68,480 KB
testcase_40 AC 72 ms
71,552 KB
testcase_41 AC 90 ms
78,976 KB
testcase_42 AC 66 ms
69,504 KB
testcase_43 AC 59 ms
66,176 KB
testcase_44 AC 75 ms
74,624 KB
testcase_45 AC 79 ms
75,776 KB
testcase_46 AC 89 ms
79,876 KB
testcase_47 AC 49 ms
61,824 KB
testcase_48 AC 91 ms
79,488 KB
testcase_49 AC 83 ms
76,032 KB
testcase_50 AC 46 ms
61,056 KB
testcase_51 AC 62 ms
67,072 KB
testcase_52 AC 102 ms
82,432 KB
testcase_53 AC 99 ms
82,140 KB
testcase_54 AC 100 ms
82,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n = int(input())
### 素数の逆元とCombination

M = 10**9+7 # 出力の制限
# M = 998244353
N = n+10 # 必要なテーブルサイズ
g1 = [0] * (N+1) # 元テーブル
g2 = [0] * (N+1) #逆元テーブル
inverse = [0] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 
for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 
def cmb(n, r, M=M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return ((g1[n] * g2[r] % M) * g2[n-r]) % M
def perm(n, r, M=M):
    if (r<0 or r>n):
        return 0
    return (g1[n] * g2[n-r]) % M
ans = cmb(n+9, 9)
print(ans)
0