結果

問題 No.1885 Flat Permutation
ユーザー hiikunZ
提出日時 2024-07-14 09:22:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 194,564 KB
最終ジャッジ日時 2025-02-22 06:36:56
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 998244353;//2024948111;
ld dotorad(ld K){ return PI * K / 180.0; }
ld radtodo(ld K){ return K * 180.0 / PI; }
mt19937 mt;
void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); }

int main(){
    ll N,X,Y;
    cin >> N >> X >> Y;
    if(X > Y) swap(X,Y);
    ll f = N - X - (N - Y) + (X == 1) + (Y == N) - 2;
    if(f < 0){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> DP(f + 1,0);
    DP[0] = 1;
    for(ll i = 1;i <= f;i++){
        DP[i] += DP[i - 1];
        if(i >= 3) DP[i] += DP[i - 3];
        DP[i] %= MOD;
    }
    cout << DP[f] << endl;
}
0