結果

問題 No.3053 2.5 色で色塗り
ユーザー chocoruskchocorusk
提出日時 2019-04-01 23:31:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 96,448 KB
実行使用メモリ 198,892 KB
最終ジャッジ日時 2023-08-18 02:45:26
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
198,716 KB
testcase_01 AC 48 ms
198,720 KB
testcase_02 AC 47 ms
198,680 KB
testcase_03 AC 46 ms
198,776 KB
testcase_04 AC 47 ms
198,840 KB
testcase_05 AC 47 ms
198,724 KB
testcase_06 AC 47 ms
198,844 KB
testcase_07 AC 47 ms
198,716 KB
testcase_08 AC 52 ms
198,892 KB
testcase_09 AC 70 ms
198,780 KB
testcase_10 AC 48 ms
198,728 KB
testcase_11 AC 63 ms
198,676 KB
testcase_12 AC 72 ms
198,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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_popcount
using 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;
}
0