結果

問題 No.391 CODING WAR
ユーザー TawaraTawara
提出日時 2015-12-29 02:29:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 26,628 KB
実行使用メモリ 4,544 KB
最終ジャッジ日時 2023-08-03 01:10:24
合計ジャッジ時間 1,493 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 21 ms
4,544 KB
testcase_10 AC 20 ms
4,496 KB
testcase_11 AC 11 ms
4,532 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 18 ms
4,524 KB
testcase_14 AC 16 ms
4,376 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 13 ms
4,376 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

typedef long long LL;

#define range(i,a,b) for(int i=(a); i < (b); i++)
#define rep(i,n) range(i,0,n)

#define U 200000
#define P 1000000007

LL mypow(LL b,LL e){
	LL ret = 1;
	for (;e>0;e>>=1){
		if(e&1) ret = ret * b % P;
		b = b * b % P;
	}
	return ret;
}
LL F[U+1],FI[U+1];
int main(){
	LL N,M,ans=0;
	scanf("%lld %lld",&N,&M);
	F[0] = 1;
	rep(i,M) F[i+1] = (i+1)*F[i]%P;
	FI[M] = mypow(F[M],P-2);
	rep(i,M) FI[M-1-i] = (M-i)*FI[M-i]%P;
	rep(k,M) ans = (ans+(k%2?-1:1)*(F[M]*FI[k]%P*FI[M-k]%P)*mypow(M-k,N)+P)%P;
	printf("%lld\n",ans);
	return 0;
}
0