結果

問題 No.391 CODING WAR
ユーザー shinchanshinchan
提出日時 2020-04-30 15:14:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,110 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 199,844 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-08-22 04:12:17
合計ジャッジ時間 3,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
8,132 KB
testcase_01 AC 7 ms
8,056 KB
testcase_02 AC 7 ms
8,008 KB
testcase_03 WA -
testcase_04 AC 7 ms
8,020 KB
testcase_05 AC 7 ms
8,208 KB
testcase_06 AC 7 ms
8,056 KB
testcase_07 AC 7 ms
8,040 KB
testcase_08 WA -
testcase_09 AC 25 ms
8,120 KB
testcase_10 AC 24 ms
8,048 KB
testcase_11 AC 15 ms
8,036 KB
testcase_12 AC 7 ms
8,120 KB
testcase_13 AC 21 ms
8,036 KB
testcase_14 AC 19 ms
8,048 KB
testcase_15 WA -
testcase_16 AC 15 ms
8,032 KB
testcase_17 AC 16 ms
8,044 KB
testcase_18 AC 14 ms
8,116 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    for(ll i=0;i<=m;i++){
    	ans += (com(m, i) * modpow(i, n) * (((m-i)&1? -1: 1)))%mod;
    	ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
0