結果

問題 No.2575 Almost Increasing Sequence
ユーザー maksimmaksim
提出日時 2023-12-09 00:10:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,797 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 169,192 KB
実行使用メモリ 17,624 KB
スコア 0
最終ジャッジ日時 2023-12-09 00:10:32
合計ジャッジ時間 24,523 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int p=998244353;
const int maxn=2e5+5;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*u)%p;} else {int u=po(a,b-1);return (a*u)%p;}}
int inv(int x) {return po(x,p-2);}
int fact[maxn];int invf[maxn];int invm[maxn];int sqi[maxn];
int arr[maxn][5];
int res[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    fact[0]=1;for(int i=1;i<maxn;++i) {fact[i]=(fact[i-1]*i)%p;} invf[maxn-1]=inv(fact[maxn-1]);for(int i=maxn-2;i>=0;--i) {invf[i]=(invf[i+1]*(i+1))%p;}
    for(int i=1;i<maxn;++i) {invm[i]=(invf[i]*fact[i-1])%p;}
    for(int i=0;i<maxn;++i) {sqi[i]=(invf[i]*invf[i])%p;}
    int k;cin>>k;
    int n=30003;
    for(int z=1;z<=n;++z)
    {
        int pok=(z>2 ? po(z-2,k) : 0);
        int x=z-1;
        for(int y=1;y<x && x+y+z<=n;++y)
        {
            int u=(sqi[x]*sqi[y])%p;
            int fo=((x-y)*(x-y)*u)%p;
            arr[x+y][4]+=fo;arr[x+y][4]%=p;
            arr[x+y][3]+=(-2*x-2*y)*fo;arr[x+y][3]%=p;
            arr[x+y][2]+=((x*x+4*x*y+y*y)%p)*fo;arr[x+y][2]%=p;
            arr[x+y][1]+=((-2*x*y*(x+y))%p)*fo;arr[x+y][1]%=p;
            arr[x+y][0]+=((x*x*y*y)%p)*fo;arr[x+y][0]%=p;
        }
        for(int h=0;h<2*z && h+z<=n;++h)
        {
            if(h+z<3) continue;
            int va=(((((pok*fact[h+z-3])%p)*fact[h+z-3])%p)*sqi[z])%p;
            int zs=1;
            for(int s=0;s<=4;++s)
            {
                res[h+z]+=(((va*zs)%p)*arr[h][s]);res[h+z]%=p;
                zs*=z;zs%=p;
            }
        }
    }
    cout<<n-3<<'\n';
    for(int i=4;i<=n;++i) {cout<<res[i];if(i!=n) cout<<' ';}
    return 0;
}
/* 0 0 1 954786991 957671876 889065338 142889101 869246692 997557100*/
0