結果

問題 No.1832 NAND Reversible
ユーザー otoshigootoshigo
提出日時 2022-02-05 14:37:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,537 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 202,236 KB
実行使用メモリ 8,904 KB
最終ジャッジ日時 2023-09-02 06:37:49
合計ジャッジ時間 4,599 ms
ジャッジサーバーID
(参考情報)
judge16 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
5,360 KB
testcase_01 WA -
testcase_02 AC 32 ms
5,192 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 36 ms
8,704 KB
testcase_06 AC 32 ms
5,312 KB
testcase_07 WA -
testcase_08 AC 36 ms
8,584 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 31 ms
5,188 KB
testcase_14 AC 32 ms
5,200 KB
testcase_15 AC 33 ms
5,900 KB
testcase_16 WA -
testcase_17 AC 36 ms
8,176 KB
testcase_18 AC 32 ms
5,308 KB
testcase_19 AC 32 ms
5,636 KB
testcase_20 AC 31 ms
5,368 KB
testcase_21 WA -
testcase_22 AC 36 ms
8,648 KB
testcase_23 AC 32 ms
5,416 KB
testcase_24 AC 32 ms
5,412 KB
testcase_25 AC 34 ms
7,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,a,b) for (int i = a; i < b; i++)
#define rrep2(i,a,b) for (int i = a-1; i >= b; i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
template<class T> T pow(T x, T y){if (y == 0) return 1.0;T p = pow(x,y/2);if (y%2 == 0) return p*p;else return p*p*x;}

const int MAX = 200010;

vector<mint> fac(MAX),finv(MAX);

void set_fac(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1]*i;
        finv[i] = finv[i-1] * mint(i).inv();
    }
}

mint cmb_mint(int n, int r){
    if (r < 0 || n < r) return 0;
    return fac[n]*finv[n-r]*finv[r];
}

vector<mint> B(200010);

mint b(int x, int y){
    if (y <= 0) B[y] = 0;
    else B[y] = cmb_mint(x+y-2,y) + b(x,y-2);
    return B[y];
}

mint a(int x, int y){
    if (y < 0) return 0;
    if (y == 0) return 1;
    return a(x,y-2) + cmb_mint(x+y-2,x-2) + 2*B[y-2];
}

int main(){
    set_fac();
    int n,k; cin >> n >> k;
    b(k,n-k);
    cout << a(k,n-k).val() << endl;
}
0