結果

問題 No.420 mod2漸化式
ユーザー NoneNone
提出日時 2021-03-13 18:56:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 852 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 55,424 KB
最終ジャッジ日時 2024-04-23 09:24:35
合計ジャッジ時間 2,674 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
54,912 KB
testcase_01 AC 45 ms
55,040 KB
testcase_02 AC 45 ms
54,528 KB
testcase_03 AC 45 ms
55,040 KB
testcase_04 AC 41 ms
54,784 KB
testcase_05 AC 42 ms
54,656 KB
testcase_06 AC 41 ms
55,040 KB
testcase_07 AC 44 ms
54,656 KB
testcase_08 AC 47 ms
54,656 KB
testcase_09 AC 45 ms
54,784 KB
testcase_10 AC 45 ms
55,040 KB
testcase_11 AC 44 ms
55,296 KB
testcase_12 AC 43 ms
55,040 KB
testcase_13 AC 43 ms
55,040 KB
testcase_14 AC 43 ms
54,912 KB
testcase_15 AC 43 ms
54,912 KB
testcase_16 AC 43 ms
54,656 KB
testcase_17 AC 43 ms
55,040 KB
testcase_18 AC 42 ms
54,912 KB
testcase_19 AC 45 ms
54,656 KB
testcase_20 AC 45 ms
54,656 KB
testcase_21 AC 44 ms
54,912 KB
testcase_22 AC 44 ms
55,168 KB
testcase_23 AC 42 ms
55,040 KB
testcase_24 AC 44 ms
55,296 KB
testcase_25 AC 45 ms
55,168 KB
testcase_26 AC 45 ms
54,528 KB
testcase_27 AC 46 ms
54,912 KB
testcase_28 AC 43 ms
54,656 KB
testcase_29 AC 42 ms
55,424 KB
testcase_30 AC 42 ms
55,040 KB
testcase_31 AC 43 ms
54,912 KB
testcase_32 AC 43 ms
55,296 KB
testcase_33 AC 42 ms
55,040 KB
testcase_34 AC 44 ms
54,528 KB
testcase_35 AC 45 ms
54,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def combination(n, r, MOD=10**9+7):
    """ O(r) """
    if not 0 <= r <= n: return 0
    r = min(r, n - r)
    numerator = reduce(lambda x, y: x * y % MOD, range(n, n - r, -1), 1)
    denominator = reduce(lambda x, y: x * y % MOD, range(1, r + 1), 1)
    return numerator * pow(denominator, MOD - 2, MOD) % MOD

def combination2(n, r):
    """ O(r) """
    if not 0 <= r <= n: return 0
    r = min(r, n - r)
    numerator = reduce(lambda x, y: x * y, range(n, n - r, -1), 1)
    denominator = reduce(lambda x, y: x * y, range(1, r + 1), 1)
    return numerator // denominator


##############################################################################################
import sys
input = sys.stdin.readline
from functools import reduce

x=int(input())

S=combination2(31,x)
T=0
C=combination2(30,x-1)
for i in range(31):
    T+=C*(1<<i)
print(S,T)
0