結果

問題 No.1035 Color Box
ユーザー 夜
提出日時 2021-07-02 20:04:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,209 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 91,644 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2023-09-11 13:12:23
合計ジャッジ時間 4,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
8,204 KB
testcase_01 AC 16 ms
8,208 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 19 ms
8,096 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 16 ms
8,068 KB
testcase_08 AC 47 ms
8,052 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 16 ms
8,040 KB
testcase_12 WA -
testcase_13 AC 40 ms
8,044 KB
testcase_14 AC 44 ms
8,204 KB
testcase_15 WA -
testcase_16 AC 16 ms
8,236 KB
testcase_17 AC 16 ms
8,176 KB
testcase_18 AC 15 ms
8,236 KB
testcase_19 AC 51 ms
8,084 KB
testcase_20 AC 16 ms
8,088 KB
testcase_21 AC 16 ms
8,040 KB
testcase_22 AC 15 ms
8,036 KB
testcase_23 AC 15 ms
8,092 KB
testcase_24 AC 16 ms
8,172 KB
testcase_25 AC 16 ms
8,204 KB
testcase_26 AC 16 ms
8,048 KB
testcase_27 AC 15 ms
8,040 KB
testcase_28 AC 16 ms
8,044 KB
testcase_29 AC 15 ms
8,052 KB
testcase_30 AC 16 ms
8,068 KB
testcase_31 AC 16 ms
8,048 KB
testcase_32 AC 16 ms
8,092 KB
testcase_33 AC 15 ms
8,044 KB
testcase_34 AC 16 ms
8,040 KB
testcase_35 AC 16 ms
8,144 KB
testcase_36 AC 16 ms
8,088 KB
testcase_37 AC 15 ms
8,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long mod = 1000000007;
long long m_pow(long long x, long long y) {
	long long ans = 1;
	while (y > 0) {
		if ((y & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return ans;
}
long long fac[200020], finv[200020], inv[200020];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200020; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
	COMinit();
	long long n, m;
	cin >> n >> m;
	long long ans = 0;
	for (int i = m; i > 0; i--) {
		if ((m - i) % 2 == 0) {
			ans += m_pow(i, n) * COM(m, i) % mod;
		}
		else {
			ans -= m_pow(i, n) * COM(m, i) % mod;
		}
		ans %= mod;
	}
	cout << ans << endl;
}
0