結果

問題 No.2391 SAN 値チェック
ユーザー pockynypockyny
提出日時 2023-07-29 02:35:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 71,648 KB
実行使用メモリ 12,996 KB
最終ジャッジ日時 2024-04-16 10:11:51
合計ジャッジ時間 3,128 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
12,800 KB
testcase_01 AC 11 ms
12,928 KB
testcase_02 AC 12 ms
12,996 KB
testcase_03 AC 42 ms
12,800 KB
testcase_04 AC 29 ms
12,928 KB
testcase_05 AC 41 ms
12,920 KB
testcase_06 AC 24 ms
12,928 KB
testcase_07 AC 23 ms
12,800 KB
testcase_08 AC 18 ms
12,800 KB
testcase_09 AC 22 ms
12,956 KB
testcase_10 AC 33 ms
12,876 KB
testcase_11 AC 13 ms
12,800 KB
testcase_12 AC 50 ms
12,928 KB
testcase_13 AC 51 ms
12,800 KB
testcase_14 AC 50 ms
12,928 KB
testcase_15 AC 51 ms
12,800 KB
testcase_16 AC 50 ms
12,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
using ll = long long;
const int MX = 400010;
ll f[MX],inv[MX],fi[MX];
constexpr ll mod = 998244353;
void solve(){
    inv[1] = 1;
    for(int i=2;i<MX;i++){
        inv[i] = mod - (mod/i)*inv[mod%i]%mod;
    }
    f[0] = fi[0] = 1;
    for(int i=1;i<MX;i++){
        f[i] = f[i-1]*i%mod;
        fi[i] = fi[i-1]*inv[i]%mod;
    }
}

ll nck(ll n, ll k){
    if(n<0 || k<0 || n<k) return 0;
    return f[n]*fi[k]%mod*fi[n-k]%mod;
}

ll pw(ll a,ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

int main(){
    int i,n; cin >> n;
    solve();
    for(i=0;i<=n;i++){
        ll val = pw(i,n - i)*fi[n - i]%mod;
        if((n - i)&1) val = (mod - val)%mod;
        cout << val << "\n";
    }
}
0