結果

問題 No.1035 Color Box
ユーザー terasaterasa
提出日時 2022-06-12 15:02:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,015 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 83,108 KB
最終ジャッジ日時 2023-10-24 11:12:53
合計ジャッジ時間 4,130 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
83,080 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 71 ms
74,476 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 122 ms
83,088 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 47 ms
61,660 KB
testcase_12 WA -
testcase_13 AC 115 ms
83,084 KB
testcase_14 AC 122 ms
83,084 KB
testcase_15 AC 128 ms
83,080 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 128 ms
83,084 KB
testcase_20 WA -
testcase_21 AC 42 ms
55,752 KB
testcase_22 AC 42 ms
55,752 KB
testcase_23 AC 42 ms
55,752 KB
testcase_24 AC 42 ms
55,752 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 42 ms
55,752 KB
testcase_29 AC 42 ms
55,752 KB
testcase_30 WA -
testcase_31 AC 43 ms
55,752 KB
testcase_32 AC 42 ms
55,752 KB
testcase_33 AC 42 ms
55,752 KB
testcase_34 AC 42 ms
55,752 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 42 ms
55,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


class Combination:
    def __init__(self, N, p):
        self.N = N
        self.p = p
        self.f = [None] * (N + 1)
        self.finv = [None] * (N + 1)
        self.inv = [None] * (N + 1)

        self.f[0] = 1
        self.f[1] = 1
        self.finv[0] = 1
        self.finv[1] = 1
        self.inv[1] = 1
        for i in range(2, N + 1):
            self.f[i] = self.f[i - 1] * i % p
            self.inv[i] = p - self.inv[p % i] * (p // i) % p
            self.finv[i] = self.finv[i - 1] * self.inv[i] % p

    def P(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.f[n] * self.finv[n - k] % self.p

    def C(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.f[n] * (self.finv[k] * self.finv[n - k] % self.p) % self.p

    # 重複組合せ
    # n種類のものからk個選ぶ
    def H(self, n, k):
        return self.C(k + n - 1, k)


N, M = map(int, input().split())
mod = 10 ** 9 + 7

comb = Combination(N, mod)
ans = 0
for i in range(M, 0, -1):
    if i & 1:
        ans -= comb.C(M, i) * pow(i, N, mod) % mod
    else:
        ans += comb.C(M, i) * pow(i, N, mod) % mod
    ans %= mod
print(ans)
0