結果

問題 No.1757 Many Many Cards
ユーザー chocoruskchocorusk
提出日時 2021-11-20 14:28:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,228 bytes
コンパイル時間 4,193 ms
コンパイル使用メモリ 188,800 KB
実行使用メモリ 19,292 KB
最終ジャッジ日時 2023-09-02 08:38:37
合計ジャッジ時間 6,031 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
19,016 KB
testcase_01 AC 7 ms
18,984 KB
testcase_02 AC 7 ms
18,984 KB
testcase_03 AC 8 ms
19,156 KB
testcase_04 AC 8 ms
19,164 KB
testcase_05 AC 7 ms
19,036 KB
testcase_06 AC 7 ms
18,996 KB
testcase_07 AC 7 ms
18,984 KB
testcase_08 AC 7 ms
19,004 KB
testcase_09 AC 7 ms
18,984 KB
testcase_10 AC 7 ms
18,992 KB
testcase_11 AC 8 ms
19,132 KB
testcase_12 AC 8 ms
19,000 KB
testcase_13 AC 7 ms
19,084 KB
testcase_14 AC 8 ms
19,156 KB
testcase_15 AC 8 ms
19,016 KB
testcase_16 AC 8 ms
19,012 KB
testcase_17 AC 7 ms
18,988 KB
testcase_18 AC 8 ms
19,292 KB
testcase_19 AC 7 ms
19,060 KB
testcase_20 AC 8 ms
19,000 KB
testcase_21 AC 16 ms
19,100 KB
testcase_22 AC 42 ms
18,988 KB
testcase_23 AC 44 ms
19,072 KB
testcase_24 AC 28 ms
19,076 KB
testcase_25 AC 37 ms
19,068 KB
testcase_26 AC 9 ms
18,992 KB
testcase_27 AC 19 ms
18,984 KB
testcase_28 AC 46 ms
19,064 KB
testcase_29 AC 36 ms
19,012 KB
testcase_30 AC 10 ms
19,008 KB
testcase_31 AC 9 ms
19,068 KB
testcase_32 AC 24 ms
18,984 KB
testcase_33 AC 15 ms
19,020 KB
testcase_34 AC 15 ms
19,000 KB
testcase_35 AC 18 ms
18,992 KB
testcase_36 AC 58 ms
18,980 KB
testcase_37 AC 59 ms
19,064 KB
testcase_38 AC 7 ms
19,004 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>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
    int n, m;cin>>m>>n;
    fac(n+m);
    mint ans=n*(mint(n).pow(2*m));
    for(int k=1; k<=n && k-1<=m; k++){
        mint x=1;
        if(k>1) x=mint(k).pow(k-2);
        ans-=comb(n, k)*comb(m, k-1)*(mint(n-k).pow(2*(m-k+1)))*f[k-1]*(mint(2).pow(k-1))*x;
    }
    cout<<ans.val()<<endl;
    return 0;
}
0