結果

問題 No.1353 Limited Sequence
ユーザー 👑 jupirojupiro
提出日時 2021-01-17 13:24:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 2,708 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 137,252 KB
実行使用メモリ 34,692 KB
最終ジャッジ日時 2023-08-19 18:59:33
合計ジャッジ時間 6,084 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 69 ms
16,232 KB
testcase_13 AC 68 ms
11,944 KB
testcase_14 AC 15 ms
11,404 KB
testcase_15 AC 47 ms
19,932 KB
testcase_16 AC 6 ms
5,416 KB
testcase_17 AC 10 ms
8,388 KB
testcase_18 AC 68 ms
16,216 KB
testcase_19 AC 100 ms
26,992 KB
testcase_20 AC 22 ms
10,500 KB
testcase_21 AC 6 ms
4,424 KB
testcase_22 AC 9 ms
7,056 KB
testcase_23 AC 61 ms
14,448 KB
testcase_24 AC 41 ms
10,672 KB
testcase_25 AC 86 ms
22,316 KB
testcase_26 AC 39 ms
11,680 KB
testcase_27 AC 20 ms
6,712 KB
testcase_28 AC 20 ms
12,728 KB
testcase_29 AC 12 ms
4,712 KB
testcase_30 AC 50 ms
9,320 KB
testcase_31 AC 30 ms
9,176 KB
testcase_32 AC 30 ms
14,836 KB
testcase_33 AC 9 ms
8,052 KB
testcase_34 AC 48 ms
20,912 KB
testcase_35 AC 16 ms
9,028 KB
testcase_36 AC 19 ms
9,644 KB
testcase_37 AC 159 ms
34,512 KB
testcase_38 AC 148 ms
34,400 KB
testcase_39 AC 152 ms
34,452 KB
testcase_40 AC 156 ms
34,400 KB
testcase_41 AC 158 ms
34,388 KB
testcase_42 AC 151 ms
34,460 KB
testcase_43 AC 161 ms
34,384 KB
testcase_44 AC 157 ms
34,692 KB
testcase_45 AC 153 ms
34,448 KB
testcase_46 AC 159 ms
34,376 KB
testcase_47 AC 75 ms
34,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;
using ull = unsigned long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); }return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long  mod = 998244353;

struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
int main()
{

	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);

	int n, L, R; cin >> n >> L >> R;
	vector<int> a(n); for (auto& e : a) cin >> e;
	vector dp(R + 1, vector<mint>(n + 1));
	for (int i = 0; i < n; i++) {
		for (int cnt = 1; cnt * (i + 1) <= R and cnt <= a[i]; cnt++) {
			dp[(i + 1) * cnt][i] = 1;
		}
	}
	for (int i = 0; i <= R; i++) {
		mint sum = 0;
		for (int j = 0; j < n; j++) {
			sum += dp[i][j];
		}
		for (int j = 0; j < n; j++) {
			for (int cnt = 1; i + cnt * (j + 1) <= R and cnt <= a[j]; cnt++) {
				dp[i + cnt * (j + 1)][j] += sum - dp[i][j];
			}
		}
	}
	mint res = 0; for (int i = L; i <= R; i++) for (auto& e : dp[i]) res += e;
	cout << res.x << "\n";
}
0