結果

問題 No.2575 Almost Increasing Sequence
ユーザー maksimmaksim
提出日時 2023-12-09 00:16:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,858 bytes
コンパイル時間 3,438 ms
コンパイル使用メモリ 169,568 KB
実行使用メモリ 12,896 KB
スコア 300,000
最終ジャッジ日時 2023-12-09 00:18:30
合計ジャッジ時間 24,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9,926 ms
12,896 KB
testcase_01 AC 9,958 ms
12,896 KB
testcase_02 AC 9,938 ms
12,896 KB
testcase_03 AC 9,948 ms
12,896 KB
testcase_04 AC 9,999 ms
12,896 KB
testcase_05 AC 9,953 ms
12,896 KB
testcase_06 AC 9,930 ms
12,896 KB
testcase_07 AC 9,955 ms
12,896 KB
testcase_08 AC 9,962 ms
12,896 KB
testcase_09 AC 9,945 ms
12,896 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
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 sqf[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;}
    for(int i=0;i<maxn;++i) {sqf[i]=(fact[i]*fact[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*sqf[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;
                if(s<4) 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