結果
問題 | No.8053 2.5 色で色塗り |
ユーザー |
![]() |
提出日時 | 2019-04-01 23:31:22 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 191 ms / 2,000 ms |
コード長 | 1,161 bytes |
コンパイル時間 | 708 ms |
コンパイル使用メモリ | 97,872 KB |
実行使用メモリ | 198,912 KB |
最終ジャッジ日時 | 2024-11-27 04:45:51 |
合計ジャッジ時間 | 3,739 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <cstdio>#include <cstring>#include <iostream>#include <string>#include <cmath>#include <bitset>#include <vector>#include <map>#include <set>#include <queue>#include <deque>#include <algorithm>#include <complex>#include <unordered_map>#include <unordered_set>#include <random>#include <cassert>#include <fstream>#define popcount __builtin_popcountusing namespace std;typedef long long int ll;typedef pair<ll, int> P;const ll MOD=1e9+7;ll powmod(ll a, ll k){ll ap=a, ans=1;while(k){if(k&1){ans*=ap;ans%=MOD;}ap=ap*ap;ap%=MOD;k>>=1;}return ans;}ll inv(ll a){return powmod(a, MOD-2);}int main(){int n, m; cin>>n>>m;ll dp[5001][5001]={};dp[1][1]=1;for(int i=2; i<=m; i++){for(int j=1; j<=i; j++){dp[i][j]=(dp[i-1][j-1]+(ll)j*dp[i-1][j])%MOD;}}ll p0=5ll*inv(2ll)%MOD;ll p=p0;ll ans=0;for(int i=1; i<=m; i++){ans+=dp[m][i]*p%MOD*powmod((p0+MOD-i)%MOD, (ll)n)%MOD;p*=(p0+MOD-i); p%=MOD;ans%=MOD;}cout<<ans<<endl;return 0;}