結果

問題 No.1353 Limited Sequence
ユーザー kotatsugamekotatsugame
提出日時 2021-01-17 13:29:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 2,684 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 66,176 KB
実行使用メモリ 33,276 KB
最終ジャッジ日時 2023-08-19 19:06:15
合計ジャッジ時間 3,831 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,672 KB
testcase_01 AC 2 ms
5,908 KB
testcase_02 AC 2 ms
5,784 KB
testcase_03 AC 2 ms
5,612 KB
testcase_04 AC 2 ms
5,760 KB
testcase_05 AC 2 ms
5,580 KB
testcase_06 AC 2 ms
5,636 KB
testcase_07 AC 2 ms
6,100 KB
testcase_08 AC 2 ms
5,908 KB
testcase_09 AC 3 ms
5,940 KB
testcase_10 AC 2 ms
5,768 KB
testcase_11 AC 2 ms
5,656 KB
testcase_12 AC 38 ms
28,884 KB
testcase_13 AC 38 ms
27,912 KB
testcase_14 AC 14 ms
13,080 KB
testcase_15 AC 28 ms
20,580 KB
testcase_16 AC 7 ms
8,964 KB
testcase_17 AC 10 ms
10,740 KB
testcase_18 AC 41 ms
28,548 KB
testcase_19 AC 49 ms
30,024 KB
testcase_20 AC 19 ms
17,264 KB
testcase_21 AC 9 ms
10,920 KB
testcase_22 AC 10 ms
11,508 KB
testcase_23 AC 35 ms
27,872 KB
testcase_24 AC 26 ms
23,064 KB
testcase_25 AC 43 ms
29,372 KB
testcase_26 AC 26 ms
22,160 KB
testcase_27 AC 17 ms
17,836 KB
testcase_28 AC 16 ms
14,532 KB
testcase_29 AC 15 ms
16,776 KB
testcase_30 AC 30 ms
25,508 KB
testcase_31 AC 22 ms
20,888 KB
testcase_32 AC 34 ms
25,284 KB
testcase_33 AC 11 ms
12,784 KB
testcase_34 AC 64 ms
32,812 KB
testcase_35 AC 21 ms
19,132 KB
testcase_36 AC 26 ms
22,376 KB
testcase_37 AC 84 ms
33,180 KB
testcase_38 AC 82 ms
33,188 KB
testcase_39 AC 79 ms
33,172 KB
testcase_40 AC 80 ms
33,136 KB
testcase_41 AC 79 ms
33,176 KB
testcase_42 AC 83 ms
33,276 KB
testcase_43 AC 80 ms
33,176 KB
testcase_44 AC 80 ms
33,160 KB
testcase_45 AC 78 ms
33,156 KB
testcase_46 AC 79 ms
33,204 KB
testcase_47 AC 86 ms
33,172 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
a.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]

ソースコード

diff #

#line 1 "a.cpp"
#include<iostream>
using namespace std;
#line 3 "/home/kotatsugame/library/math/modint.cpp"
#include<utility>
template<int m>
struct modint{
	unsigned int x;
	constexpr modint()noexcept:x(){}
	template<typename T>
	constexpr modint(T x_)noexcept:x((x_%=m)<0?x_+m:x_){}
	constexpr unsigned int val()const noexcept{return x;}
	constexpr modint&operator++()noexcept{if(++x==m)x=0;return*this;}
	constexpr modint&operator--()noexcept{if(x==0)x=m;--x;return*this;}
	constexpr modint operator++(int)noexcept{modint res=*this;++*this;return res;}
	constexpr modint operator--(int)noexcept{modint res=*this;--*this;return res;}
	constexpr modint&operator+=(const modint&a)noexcept{x+=a.x;if(x>=m)x-=m;return*this;}
	constexpr modint&operator-=(const modint&a)noexcept{if(x<a.x)x+=m;x-=a.x;return*this;}
	constexpr modint&operator*=(const modint&a)noexcept{x=(unsigned long long)x*a.x%m;return*this;}
	constexpr modint&operator/=(const modint&a)noexcept{return*this*=a.inv();}
	constexpr modint operator+()const noexcept{return*this;}
	constexpr modint operator-()const noexcept{return modint()-*this;}
	constexpr modint pow(long long n)const noexcept
	{
		if(n<0)return pow(-n).inv();
		modint x=*this,r=1;
		for(;n;x*=x,n>>=1)if(n&1)r*=x;
		return r;
	}
	constexpr modint inv()const noexcept
	{
		int s=x,t=m,x=1,u=0;
		while(t)
		{
			int k=s/t;
			s-=k*t;
			swap(s,t);
			x-=k*u;
			swap(x,u);
		}
		return modint(x);
	}
	friend constexpr modint operator+(const modint&a,const modint&b){return modint(a)+=b;}
	friend constexpr modint operator-(const modint&a,const modint&b){return modint(a)-=b;}
	friend constexpr modint operator*(const modint&a,const modint&b){return modint(a)*=b;}
	friend constexpr modint operator/(const modint&a,const modint&b){return modint(a)/=b;}
	friend constexpr bool operator==(const modint&a,const modint&b){return a.x==b.x;}
	friend constexpr bool operator!=(const modint&a,const modint&b){return a.x!=b.x;}
	friend ostream&operator<<(ostream&os,const modint&a){return os<<a.x;}
	friend istream&operator>>(istream&is,modint&a){long long v;is>>v;a=modint(v);return is;}
};
#line 4 "a.cpp"
using mint=modint<998244353>;
int N,L,R;
int A[2020];
mint dp[2020][2020];
mint add[2020][2020];
main()
{
	cin>>N>>L>>R;
	for(int i=1;i<=N;i++)cin>>A[i];
	dp[0][0]=1;
	for(int s=0;s<=R;s++)
	{
		mint all=0;
		for(int j=0;j<=N;j++)
		{
			all+=dp[s][j]+=add[s][j];
			if(s+j<=R)add[s+j][j]+=add[s][j];
		}
		for(int j=1;j<=N;j++)
		{
			mint now=all-dp[s][j];
			if(s+j<=R)
			{
				add[s+j][j]+=now;
				if(s+(A[j]+1)*j<=R)add[s+(A[j]+1)*j][j]-=now;
			}
		}
	}
	mint ans=0;
	for(int i=L;i<=R;i++)for(int j=1;j<=N;j++)ans+=dp[i][j];
	cout<<ans<<endl;
}
0