結果

問題 No.1035 Color Box
ユーザー RhoRho
提出日時 2020-04-24 21:31:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 165,940 KB
実行使用メモリ 6,800 KB
最終ジャッジ日時 2023-08-05 04:32:30
合計ジャッジ時間 4,286 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
6,608 KB
testcase_01 AC 31 ms
6,516 KB
testcase_02 AC 30 ms
6,492 KB
testcase_03 AC 31 ms
6,608 KB
testcase_04 AC 31 ms
6,608 KB
testcase_05 AC 30 ms
6,672 KB
testcase_06 AC 30 ms
6,496 KB
testcase_07 AC 30 ms
6,608 KB
testcase_08 AC 37 ms
6,488 KB
testcase_09 AC 33 ms
6,800 KB
testcase_10 AC 30 ms
6,488 KB
testcase_11 AC 30 ms
6,624 KB
testcase_12 AC 30 ms
6,516 KB
testcase_13 AC 35 ms
6,516 KB
testcase_14 AC 36 ms
6,468 KB
testcase_15 AC 38 ms
6,488 KB
testcase_16 AC 30 ms
6,556 KB
testcase_17 AC 30 ms
6,556 KB
testcase_18 AC 30 ms
6,492 KB
testcase_19 AC 38 ms
6,608 KB
testcase_20 AC 30 ms
6,544 KB
testcase_21 AC 30 ms
6,560 KB
testcase_22 AC 30 ms
6,604 KB
testcase_23 AC 30 ms
6,476 KB
testcase_24 AC 31 ms
6,496 KB
testcase_25 AC 30 ms
6,492 KB
testcase_26 AC 30 ms
6,496 KB
testcase_27 AC 30 ms
6,544 KB
testcase_28 AC 31 ms
6,512 KB
testcase_29 AC 30 ms
6,476 KB
testcase_30 AC 30 ms
6,660 KB
testcase_31 AC 30 ms
6,604 KB
testcase_32 AC 30 ms
6,672 KB
testcase_33 AC 31 ms
6,468 KB
testcase_34 AC 30 ms
6,472 KB
testcase_35 AC 31 ms
6,692 KB
testcase_36 AC 30 ms
6,504 KB
testcase_37 AC 30 ms
6,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long mod = 1000000007;
const long long inf = 1ll<<61;

int kj[200006], kji[200006];
int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod;
		x >>= 1;
	}
	return res;
}
void setkj() {
	kj[0] = 1;
	rep(i, 200005) {
		kj[i + 1] = kj[i] * (i + 1) % mod;
		kji[i] = modpow(kj[i], mod - 2);
	}
}
int comb(int n, int r) {
	return kj[n] * kji[r] % mod*kji[n - r] % mod;
}
signed main() {
	int n, m; cin >> n >> m;
	int ans = 0;
	setkj();
	for(int i=1;i<=m;i++) {
		if ((m - i) & 1)ans -= comb(m, i)*modpow(i, n) % mod;
		else ans += comb(m, i)*modpow(i, n) % mod;
		ans = (ans + mod) % mod;
	}
	cout << ans << endl;
}
0