結果

問題 No.391 CODING WAR
ユーザー nxterunxteru
提出日時 2018-10-29 23:00:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 1,725 ms
コンパイル使用メモリ 167,308 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 23:54:47
合計ジャッジ時間 2,238 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 24 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M 1000000009
ll n,m,ans,k[100005],r[100005];
ll pw(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=res*a%M;
		b>>=1;
		a=a*a%M;
	}
	return res;
}
ll cm(ll a,ll b){
	return k[a]*r[b]%M*r[a-b]%M;
}
int main(void){
    cin>>n>>m;
    k[0]=1,r[0]=1;
    for(ll i=1;i<=m;i++){
		k[i]=k[i-1]*i%M;
		r[i]=pw(k[i],M-2);
	}
	ans=pw(m,n);
	for(ll i=1;i<=m;i++){
		if(i%2)ans=(ans+M-cm(m,i)*pw(m-i,n)%M)%M;
		else ans=(ans+cm(m,i)*pw(m-i,n)%M)%M;
	}
	cout<<ans<<endl;
}
0