結果
問題 | No.2747 Permutation Adjacent Sum |
ユーザー | GOTKAKO |
提出日時 | 2024-04-20 17:04:21 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,138 bytes |
コンパイル時間 | 2,276 ms |
コンパイル使用メモリ | 205,260 KB |
実行使用メモリ | 16,704 KB |
最終ジャッジ日時 | 2024-10-12 12:56:24 |
合計ジャッジ時間 | 10,759 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; long long mod = 998244353; //入力が必ずmod未満の時に使う. struct mint{ long long v = 0; mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;} long long val(){return v;} void modu(){v %= mod;} mint repeat2mint(long long a,long long b){ mint ret = 1,p = a; while(b){if(b&1) ret *= p; p *= p; b >>= 1;} return ret; }; mint operator-(){return mint(0)-mint(v);} mint operator+(mint b){return (v+b.v)%mod;} mint operator-(mint b){return (v-b.v+mod)%mod;} mint operator*(mint b){return v*b.v%mod;} mint operator/(mint b){ if(b.v == 0) assert(false); return v*(repeat2mint(b.v,mod-2)).v%mod; } void operator+=(mint b){v = (v+b.v)%mod;} void operator-=(mint b){v = (v-b.v+mod)%mod;} void operator*=(mint b){v = v*b.v%mod;} void operator/=(mint b){ if(b.v == 0) assert(false); v = v*repeat2mint(b.v,mod-2).v%mod; } void operator++(int){v = (v+1)%mod; return;} void operator--(int){v = (v-1+mod)%mod; return;} bool operator==(mint b){return v == b.v;} bool operator!=(mint b){return v != b.v;} bool operator>(mint b) {return v > b.v;} bool operator>=(mint b){return v >= b.v;} bool operator<(mint b) {return v < b.v;} bool operator<=(mint b){return v <= b.v;} mint pow(long long x){return repeat2mint(v,x);} mint inv(){return mint(1)/v;} }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,K; cin >> N >> K; /* vector<int> P(N); iota(P.begin(),P.end(),1); vector<int> diff(N); do{ for(int i=0; i<N-1; i++) diff.at(abs(P.at(i+1)-P.at(i)))++; }while(next_permutation(P.begin(),P.end())); for(auto d : diff) cout << d << " " ; cout << endl; */ N--; if(N >= mod){cout << 0 << endl; return 0;} vector<mint> ume = {1,295201906,160030060,957629942,545208507,213689172,760025067,939830261,506268060,39806322,808258749,440133909,686156489,741797144,390377694,12629586,544711799,104121967,495867250,421290700,117153405,57084755,202713771,675932866,79781699,956276337,652678397,35212756,655645460,468129309,761699708,533047427,287671032,206068022,50865043,144980423,111276893,259415897,444094191,593907889,573994984,892454686,566073550,128761001,888483202,251718753,548033568,428105027,742756734,546182474,62402409,102052166,826426395,159186619,926316039,176055335,51568171,414163604,604947226,681666415,511621808,924112080,265769800,955559118,763148293,472709375,19536133,860830935,290471030,851685235,242726978,169855231,612759169,599797734,961628039,953297493,62806842,37844313,909741023,689361523,887890124,380694152,669317759,367270918,806951470,843736533,377403437,945260111,786127243,80918046,875880304,364983542,623250998,598764068,804930040,24257676,214821357,791011898,954947696,183092975}; mint now = ume.at(N/(int)1e7)*2; for(int i=N-N%(int)1e7+1; i<=N; i++) now *= i; N++; mint now2 = 0; for(int i=1; i<=N; i++) now2 += mint(N-i).pow(K)*i; cout << (now*now2).v << endl; }