結果

問題 No.420 mod2漸化式
ユーザー yomo3yomo3
提出日時 2020-03-16 18:06:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 23 ms / 1,000 ms
コード長 693 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,792 KB
最終ジャッジ日時 2023-08-18 19:23:13
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
8,740 KB
testcase_01 AC 22 ms
8,756 KB
testcase_02 AC 20 ms
8,792 KB
testcase_03 AC 20 ms
8,632 KB
testcase_04 AC 21 ms
8,716 KB
testcase_05 AC 20 ms
8,552 KB
testcase_06 AC 20 ms
8,708 KB
testcase_07 AC 20 ms
8,556 KB
testcase_08 AC 20 ms
8,592 KB
testcase_09 AC 20 ms
8,744 KB
testcase_10 AC 20 ms
8,740 KB
testcase_11 AC 20 ms
8,792 KB
testcase_12 AC 20 ms
8,600 KB
testcase_13 AC 20 ms
8,744 KB
testcase_14 AC 20 ms
8,716 KB
testcase_15 AC 20 ms
8,756 KB
testcase_16 AC 20 ms
8,784 KB
testcase_17 AC 20 ms
8,744 KB
testcase_18 AC 21 ms
8,768 KB
testcase_19 AC 20 ms
8,608 KB
testcase_20 AC 21 ms
8,600 KB
testcase_21 AC 20 ms
8,568 KB
testcase_22 AC 20 ms
8,576 KB
testcase_23 AC 21 ms
8,608 KB
testcase_24 AC 20 ms
8,576 KB
testcase_25 AC 21 ms
8,556 KB
testcase_26 AC 21 ms
8,600 KB
testcase_27 AC 21 ms
8,688 KB
testcase_28 AC 20 ms
8,632 KB
testcase_29 AC 20 ms
8,640 KB
testcase_30 AC 20 ms
8,756 KB
testcase_31 AC 20 ms
8,712 KB
testcase_32 AC 21 ms
8,604 KB
testcase_33 AC 21 ms
8,552 KB
testcase_34 AC 21 ms
8,688 KB
testcase_35 AC 20 ms
8,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import reduce

def comb(n, r):
    if n < 0 or r < 0 or r > n:
        return 0
    r = min(r, n - r)
    if r == 0: return 1

    numer = [n - r + i + 1 for i in range(r)]
    denom = [i + 1 for i in range(r)]

    for i in range(1, r):
        divisor = denom[i]
        if divisor > 1:
            offset = (n - r) % (i + 1)
            for j in range(i, r, i+1):
                numer[j - offset] //= divisor
                denom[j] //= divisor

    return reduce(lambda x, y: x*y if y > 1 else x, numer)

def main():
    X = int(input())
    if X == 0:
        print(1, 0)
    else:
        c = comb(31, X)
        s = c * X // 31 * (2**31 - 1)
        print(c, s)

main()
0