#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ using Mint = atcoder::modint998244353; void Solve() { int n, m; IN(n, m); vector x(n), y(n); vector p(n); vector S(n); for (int i : Rep(0, n)) { IN(x[i], y[i], p[i], S[i]); p[i] /= 100; } vector order(ALL(Rep(0, n))); ranges::stable_sort(order, greater{}, LAMBDA(i, S[i])); Mint ans = 0; while (m--) { int64_t t; IN(t); Mint cur = 1; for (int i : order) { int64_t q = t / x[i]; int64_t l = (Ceil(t + 1, x[i], y[i]) - y[i]) / x[i]; SetMax(l, 1); if (l <= q) { Mint prob = 1 - (1 - p[i]).pow(q - l + 1); ans += cur * prob * S[i]; cur *= 1 - prob; } } ans += cur; } OUT(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include #include template concept MyRange = std::ranges::range && !std::convertible_to && !std::convertible_to; template concept MyTuple = std::__is_tuple_like::value && !MyRange; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) { is >> e; } return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) { os << exchange(sep, " ") << forward(e); } return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } template * = nullptr> istream& operator>>(istream& is, T& x) { int v; is >> v; x = T::raw(v); return is; } template * = nullptr> ostream& operator<<(ostream& os, const T& x) { return os << x.val(); } } // namespace std template class OneBased { public: explicit OneBased(T&& x) : ref_(std::forward(x)) {} template requires(sizeof...(Ts) > 1) OneBased(Ts&&... xs) : ref_(std::forward_as_tuple(std::forward(xs)...)) {} friend std::istream& operator>>(std::istream& is, OneBased x) { if constexpr (MyRange) { for (auto&& e : x.ref_) { is >> ::OneBased(e); } } else if constexpr (MyTuple) { std::apply([&](auto&... xs) { (is >> ... >> ::OneBased(xs)); }, x.ref_); } else { is >> x.ref_; --x.ref_; } return is; } friend std::ostream& operator<<(std::ostream& os, OneBased x) { if constexpr (MyRange) { auto f = [](auto&& e) { return ::OneBased(std::forward(e)); }; os << (x.ref_ | std::views::transform(f)); } else if constexpr (MyTuple) { std::apply([&](auto&... xs) { os << std::tuple(::OneBased(xs)...); }, x.ref_); } else { os << ++x.ref_; --x.ref_; } return os; } private: T ref_; }; template OneBased(T&&) -> OneBased; template OneBased(Ts&&...) -> OneBased>; using namespace std; #define LAMBDA(x, ...) ([&](auto&& x) -> decltype(auto) { return __VA_ARGS__; }) #define LAMBDA2(x, y, ...) ([&](auto&& x, auto&& y) -> decltype(auto) { return __VA_ARGS__; }) #define LAMBDA3(x, y, z, ...) ([&](auto&& x, auto&& y, auto&& z) -> decltype(auto) { return __VA_ARGS__; }) #define ALL(r) begin(r), end(r) #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define SetMax(...) LAMBDA2(x, y, x < y && (x = y, 1))(__VA_ARGS__) #define DivCeil(...) LAMBDA2(x, y, x / y + ((x ^ y) >= 0 && x % y))(__VA_ARGS__) #define Ceil(...) LAMBDA3(x, m, r, DivCeil(x - r, m) * m + r)(__VA_ARGS__) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1