QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#120635 | #6678. Gem Island 2 | pachicobue | AC ✓ | 1212ms | 315908kb | C++23 | 22.0kb | 2023-07-07 02:39:44 | 2024-04-23 17:43:58 |
Judging History
你现在查看的是最新测评结果
- [2024-04-23 17:43:38]
- hack成功,自动添加数据
- (/hack/600)
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-07 02:39:44]
- 提交
answer
#include <bits/stdc++.h>
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
using f64 = double;
using f80 = long double;
using f128 = __float128;
constexpr i32 operator"" _i32(u64 v) { return v; }
constexpr u32 operator"" _u32(u64 v) { return v; }
constexpr i64 operator"" _i64(u64 v) { return v; }
constexpr u64 operator"" _u64(u64 v) { return v; }
constexpr f64 operator"" _f64(f80 v) { return v; }
constexpr f80 operator"" _f80(f80 v) { return v; }
using Istream = std::istream;
using Ostream = std::ostream;
using Str = std::string;
template<typename T>
using Lt = std::less<T>;
template<typename T>
using Gt = std::greater<T>;
template<int n>
using BSet = std::bitset<n>;
template<typename T1, typename T2>
using Pair = std::pair<T1, T2>;
template<typename... Ts>
using Tup = std::tuple<Ts...>;
template<typename T, int N>
using Arr = std::array<T, N>;
template<typename... Ts>
using Deq = std::deque<Ts...>;
template<typename... Ts>
using Set = std::set<Ts...>;
template<typename... Ts>
using MSet = std::multiset<Ts...>;
template<typename... Ts>
using USet = std::unordered_set<Ts...>;
template<typename... Ts>
using UMSet = std::unordered_multiset<Ts...>;
template<typename... Ts>
using Map = std::map<Ts...>;
template<typename... Ts>
using MMap = std::multimap<Ts...>;
template<typename... Ts>
using UMap = std::unordered_map<Ts...>;
template<typename... Ts>
using UMMap = std::unordered_multimap<Ts...>;
template<typename... Ts>
using Vec = std::vector<Ts...>;
template<typename... Ts>
using Stack = std::stack<Ts...>;
template<typename... Ts>
using Queue = std::queue<Ts...>;
template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, Vec<T>, Gt<T>>;
constexpr bool LOCAL = false;
constexpr bool OJ = not LOCAL;
template<typename T>
static constexpr T OjLocal(T oj, T local)
{
return LOCAL ? local : oj;
}
template<typename T>
constexpr T LIMMIN = std::numeric_limits<T>::min();
template<typename T>
constexpr T LIMMAX = std::numeric_limits<T>::max();
template<typename T = i64>
constexpr T INF = (LIMMAX<T> - 1) / 2;
template<typename T = f80>
constexpr T PI = T{3.141592653589793238462643383279502884};
template<typename T = u64>
constexpr T TEN(int n)
{
return n == 0 ? T{1} : TEN<T>(n - 1) * T{10};
}
template<typename T>
constexpr bool chmin(T& a, const T& b)
{
return (a > b ? (a = b, true) : false);
}
template<typename T>
constexpr bool chmax(T& a, const T& b)
{
return (a < b ? (a = b, true) : false);
}
template<typename T>
constexpr T floorDiv(T x, T y)
{
assert(y != 0);
if (y < 0) { x = -x, y = -y; }
return x >= 0 ? x / y : (x - y + 1) / y;
}
template<typename T>
constexpr T ceilDiv(T x, T y)
{
assert(y != 0);
if (y < 0) { x = -x, y = -y; }
return x >= 0 ? (x + y - 1) / y : x / y;
}
template<typename T, typename I>
constexpr T powerMonoid(T v, I n, const T& e)
{
assert(n >= 0);
if (n == 0) { return e; }
return (n % 2 == 1 ? v * powerMonoid(v, n - 1, e) : powerMonoid(v * v, n / 2, e));
}
template<typename T, typename I>
constexpr T powerInt(T v, I n)
{
return powerMonoid(v, n, T{1});
}
template<typename Vs, typename... Args>
constexpr auto accumAll(const Vs& vs, Args... args)
{
return std::accumulate(std::begin(vs), std::end(vs), args...);
}
template<typename Vs>
constexpr auto sumAll(const Vs& vs)
{
return accumAll(vs, decltype(vs[0]){});
}
template<typename Vs>
constexpr auto gcdAll(const Vs& vs)
{
return accumAll(vs, decltype(vs[0]){}, [&](auto v1, auto v2) { return std::gcd(v1, v2); });
}
template<typename Vs, typename V>
constexpr int lbInd(const Vs& vs, const V& v)
{
return std::lower_bound(std::begin(vs), std::end(vs), v) - std::begin(vs);
}
template<typename Vs, typename V>
constexpr int ubInd(const Vs& vs, const V& v)
{
return std::upper_bound(std::begin(vs), std::end(vs), v) - std::begin(vs);
}
template<typename Vs>
constexpr void concat(Vs& vs1, const Vs vs2)
{
std::copy(std::begin(vs2), std::end(vs2), std::back_inserter(vs1));
}
template<typename Vs>
constexpr Vs concatted(Vs vs1, const Vs& vs2)
{
concat(vs1, vs2);
return vs1;
}
template<typename Vs, typename V>
constexpr void fillAll(Vs& arr, const V& v)
{
if constexpr (std::is_convertible<V, Vs>::value) {
arr = v;
} else {
for (auto& subarr : arr) { fillAll(subarr, v); }
}
}
template<typename T, typename F>
constexpr Vec<T> genVec(int n, F gen)
{
Vec<T> ans;
std::generate_n(std::back_inserter(ans), n, gen);
return ans;
}
template<typename Vs>
constexpr auto maxAll(const Vs& vs)
{
return *std::max_element(std::begin(vs), std::end(vs));
}
template<typename Vs>
constexpr auto minAll(const Vs& vs)
{
return *std::min_element(std::begin(vs), std::end(vs));
}
template<typename Vs>
constexpr auto maxInd(const Vs& vs)
{
return *std::max_element(std::begin(vs), std::end(vs));
}
template<typename Vs>
constexpr int minInd(const Vs& vs)
{
return std::min_element(std::begin(vs), std::end(vs)) - std::begin(vs);
}
template<typename Vs>
constexpr int maxInd(const Vs& vs)
{
return std::max_element(std::begin(vs), std::end(vs)) - std::begin(vs);
}
template<typename T = int>
constexpr Vec<T> iotaVec(int n, T offset = 0)
{
Vec<T> ans(n);
std::iota(std::begin(ans), std::end(ans), offset);
return ans;
}
template<typename Vs>
constexpr Vec<int> iotaSort(const Vs& vs)
{
auto is = iotaVec(vs.size());
std::sort(std::begin(is), std::end(is), [&](int i, int j) { return vs[i] < vs[j]; });
return is;
}
inline Vec<int> permInv(const Vec<int>& is)
{
auto ris = is;
for (int i = 0; i < (int)is.size(); i++) { ris[is[i]] = i; }
return ris;
}
template<typename Vs, typename V>
constexpr void plusAll(Vs& vs, const V& v)
{
for (auto& v_ : vs) { v_ += v; }
}
template<typename Vs>
constexpr void reverseAll(Vs& vs)
{
std::reverse(std::begin(vs), std::end(vs));
}
template<typename Vs>
constexpr Vs reversed(Vs vs)
{
reverseAll(vs);
return vs;
}
template<typename Vs, typename... Args>
constexpr void sortAll(Vs& vs, Args... args)
{
std::sort(std::begin(vs), std::end(vs), args...);
}
template<typename Vs, typename... Args>
constexpr Vs sorted(Vs vs, Args... args)
{
sortAll(vs, args...);
return vs;
}
inline Ostream& operator<<(Ostream& os, i128 v)
{
bool minus = false;
if (v < 0) { minus = true, v = -v; }
Str ans;
if (v == 0) { ans = "0"; }
while (v) { ans.push_back('0' + v % 10), v /= 10; }
std::reverse(ans.begin(), ans.end());
return os << (minus ? "-" : "") << ans;
}
inline Ostream& operator<<(Ostream& os, u128 v)
{
Str ans;
if (v == 0) { ans = "0"; }
while (v) { ans.push_back('0' + v % 10), v /= 10; }
std::reverse(ans.begin(), ans.end());
return os << ans;
}
constexpr bool isBitOn(u64 mask, int ind) { return (mask >> ind) & 1_u64; }
constexpr bool isBitOff(u64 mask, int ind) { return not isBitOn(mask, ind); }
constexpr int topBit(u64 v) { return v == 0 ? -1 : 63 - __builtin_clzll(v); }
constexpr int lowBit(u64 v) { return v == 0 ? 64 : __builtin_ctzll(v); }
constexpr int bitWidth(u64 v) { return topBit(v) + 1; }
constexpr u64 bitCeil(u64 v) { return v ? (1_u64 << bitWidth(v - 1)) : 1_u64; }
constexpr u64 bitFloor(u64 v) { return v ? (1_u64 << topBit(v)) : 0_u64; }
constexpr bool hasSingleBit(u64 v) { return (v > 0) and ((v & (v - 1)) == 0); }
constexpr u64 bitMask(int bitWidth) { return (bitWidth == 64 ? ~0_u64 : (1_u64 << bitWidth) - 1); }
constexpr u64 bitMask(int start, int end) { return bitMask(end - start) << start; }
constexpr int popCount(u64 v) { return v ? __builtin_popcountll(v) : 0; }
constexpr bool popParity(u64 v) { return v > 0 and __builtin_parity(v) == 1; }
template<typename F>
struct Fix : F
{
constexpr Fix(F&& f) : F{std::forward<F>(f)} {}
template<typename... Args>
constexpr auto operator()(Args&&... args) const
{
return F::operator()(*this, std::forward<Args>(args)...);
}
};
class irange
{
private:
struct itr
{
constexpr itr(i64 start = 0, i64 step = 1) : m_cnt{start}, m_step{step} {}
constexpr bool operator!=(const itr& it) const { return m_cnt != it.m_cnt; }
constexpr i64 operator*() { return m_cnt; }
constexpr itr& operator++() { return m_cnt += m_step, *this; }
i64 m_cnt, m_step;
};
i64 m_start, m_end, m_step;
public:
static constexpr i64 cnt(i64 start, i64 end, i64 step)
{
if (step == 0) { return -1; }
const i64 d = (step > 0 ? step : -step);
const i64 l = (step > 0 ? start : end);
const i64 r = (step > 0 ? end : start);
i64 n = (r - l) / d + ((r - l) % d ? 1 : 0);
if (l >= r) { n = 0; }
return n;
}
constexpr irange(i64 start, i64 end, i64 step = 1)
: m_start{start}, m_end{m_start + step * cnt(start, end, step)}, m_step{step}
{
assert(step != 0);
}
constexpr itr begin() const { return itr{m_start, m_step}; }
constexpr itr end() const { return itr{m_end, m_step}; }
};
constexpr irange rep(i64 end) { return irange(0, end, 1); }
constexpr irange per(i64 rend) { return irange(rend - 1, -1, -1); }
class Scanner
{
public:
Scanner(Istream& is = std::cin) : m_is{is} { m_is.tie(nullptr)->sync_with_stdio(false); }
template<typename T>
T val()
{
T v;
return m_is >> v, v;
}
template<typename T>
T val(T offset)
{
return val<T>() - offset;
}
template<typename T>
Vec<T> vec(int n)
{
return genVec<T>(n, [&]() { return val<T>(); });
}
template<typename T>
Vec<T> vec(int n, T offset)
{
return genVec<T>(n, [&]() { return val<T>(offset); });
}
template<typename T>
Vec<Vec<T>> vvec(int n, int m)
{
return genVec<Vec<T>>(n, [&]() { return vec<T>(m); });
}
template<typename T>
Vec<Vec<T>> vvec(int n, int m, const T offset)
{
return genVec<Vec<T>>(n, [&]() { return vec<T>(m, offset); });
}
template<typename... Args>
auto tup()
{
return Tup<Args...>{val<Args>()...};
}
template<typename... Args>
auto tup(Args... offsets)
{
return Tup<Args...>{val<Args>(offsets)...};
}
private:
Istream& m_is;
};
inline Scanner in;
class Printer
{
public:
Printer(Ostream& os = std::cout) : m_os{os} { m_os << std::fixed << std::setprecision(15); }
template<typename... Args>
int operator()(const Args&... args)
{
return dump(args...), 0;
}
template<typename... Args>
int ln(const Args&... args)
{
return dump(args...), m_os << '\n', 0;
}
template<typename... Args>
int el(const Args&... args)
{
return dump(args...), m_os << std::endl, 0;
}
int YES(bool b = true) { return ln(b ? "YES" : "NO"); }
int NO(bool b = true) { return YES(not b); }
int Yes(bool b = true) { return ln(b ? "Yes" : "No"); }
int No(bool b = true) { return Yes(not b); }
private:
template<typename T>
void dump(const T& v)
{
m_os << v;
}
template<typename T>
void dump(const Vec<T>& vs)
{
for (int i : rep(vs.size())) { m_os << (i ? " " : ""), dump(vs[i]); }
}
template<typename T>
void dump(const Vec<Vec<T>>& vss)
{
for (int i : rep(vss.size())) { m_os << (i ? "\n" : ""), dump(vss[i]); }
}
template<typename T, typename... Ts>
int dump(const T& v, const Ts&... args)
{
return dump(v), m_os << ' ', dump(args...), 0;
}
Ostream& m_os;
};
inline Printer out;
template<typename T, int n, int i = 0>
auto ndVec(int const (&szs)[n], const T x = T{})
{
if constexpr (i == n) {
return x;
} else {
return std::vector(szs[i], ndVec<T, n, i + 1>(szs, x));
}
}
template<typename T, typename F>
inline T binSearch(T ng, T ok, F check)
{
while (std::abs(ok - ng) > 1) {
const T mid = (ok + ng) / 2;
(check(mid) ? ok : ng) = mid;
}
return ok;
}
template<typename T, typename F>
inline T fbinSearch(T ng, T ok, F check, int times)
{
for (auto _temp_name_0 [[maybe_unused]] : rep(times)) {
const T mid = (ok + ng) / 2;
(check(mid) ? ok : ng) = mid;
}
return ok;
}
template<typename T>
constexpr T clampAdd(T x, T y, T min, T max)
{
return std::clamp(x + y, min, max);
}
template<typename T>
constexpr T clampSub(T x, T y, T min, T max)
{
return std::clamp(x - y, min, max);
}
template<typename T>
constexpr T clampMul(T x, T y, T min, T max)
{
if (y < 0) { x = -x, y = -y; }
const T xmin = ceilDiv(min, y);
const T xmax = floorDiv(max, y);
if (x < xmin) {
return min;
} else if (x > xmax) {
return max;
} else {
return x * y;
}
}
template<typename T>
constexpr T clampDiv(T x, T y, T min, T max)
{
return std::clamp(floorDiv(x, y), min, max);
}
template<typename T>
constexpr Pair<T, T> extgcd(const T a, const T b) // [x,y] -> ax+by=gcd(a,b)
{
static_assert(std::is_signed_v<T>, "Signed integer is allowed.");
assert(a != 0 or b != 0);
if (a >= 0 and b >= 0) {
if (a < b) {
const auto [y, x] = extgcd(b, a);
return {x, y};
}
if (b == 0) { return {1, 0}; }
const auto [x, y] = extgcd(b, a % b);
return {y, x - (a / b) * y};
} else {
auto [x, y] = extgcd(std::abs(a), std::abs(b));
if (a < 0) { x = -x; }
if (b < 0) { y = -y; }
return {x, y};
}
}
template<typename T>
constexpr T inverse(const T a, const T mod) // ax=gcd(a,M) (mod M)
{
assert(a > 0 and mod > 0);
auto [x, y] = extgcd(a, mod);
if (x <= 0) { x += mod; }
return x;
}
template<u32 mod_, u32 root_, u32 max2p_>
class modint
{
template<typename U = u32&>
static U modRef()
{
static u32 s_mod = 0;
return s_mod;
}
template<typename U = u32&>
static U rootRef()
{
static u32 s_root = 0;
return s_root;
}
template<typename U = u32&>
static U max2pRef()
{
static u32 s_max2p = 0;
return s_max2p;
}
public:
static_assert(mod_ <= LIMMAX<i32>, "mod(signed int size) only supported!");
static constexpr bool isDynamic() { return (mod_ == 0); }
template<typename U = const u32>
static constexpr std::enable_if_t<mod_ != 0, U> mod()
{
return mod_;
}
template<typename U = const u32>
static std::enable_if_t<mod_ == 0, U> mod()
{
return modRef();
}
template<typename U = const u32>
static constexpr std::enable_if_t<mod_ != 0, U> root()
{
return root_;
}
template<typename U = const u32>
static std::enable_if_t<mod_ == 0, U> root()
{
return rootRef();
}
template<typename U = const u32>
static constexpr std::enable_if_t<mod_ != 0, U> max2p()
{
return max2p_;
}
template<typename U = const u32>
static std::enable_if_t<mod_ == 0, U> max2p()
{
return max2pRef();
}
template<typename U = u32>
static void setMod(std::enable_if_t<mod_ == 0, U> m)
{
assert(1 <= m and m <= LIMMAX<i32>);
modRef() = m;
sinvRef() = {1, 1};
factRef() = {1, 1};
ifactRef() = {1, 1};
}
template<typename U = u32>
static void setRoot(std::enable_if_t<mod_ == 0, U> r)
{
rootRef() = r;
}
template<typename U = u32>
static void setMax2p(std::enable_if_t<mod_ == 0, U> m)
{
max2pRef() = m;
}
constexpr modint() : m_val{0} {}
constexpr modint(i64 v) : m_val{normll(v)} {}
constexpr void setRaw(u32 v) { m_val = v; }
constexpr modint operator-() const { return modint{0} - (*this); }
constexpr modint& operator+=(const modint& m)
{
m_val = norm(m_val + m.val());
return *this;
}
constexpr modint& operator-=(const modint& m)
{
m_val = norm(m_val + mod() - m.val());
return *this;
}
constexpr modint& operator*=(const modint& m)
{
m_val = normll((i64)m_val * (i64)m.val() % (i64)mod());
return *this;
}
constexpr modint& operator/=(const modint& m) { return *this *= m.inv(); }
constexpr modint operator+(const modint& m) const
{
auto v = *this;
return v += m;
}
constexpr modint operator-(const modint& m) const
{
auto v = *this;
return v -= m;
}
constexpr modint operator*(const modint& m) const
{
auto v = *this;
return v *= m;
}
constexpr modint operator/(const modint& m) const
{
auto v = *this;
return v /= m;
}
constexpr bool operator==(const modint& m) const { return m_val == m.val(); }
constexpr bool operator!=(const modint& m) const { return not(*this == m); }
friend Istream& operator>>(Istream& is, modint& m)
{
i64 v;
return is >> v, m = v, is;
}
friend Ostream& operator<<(Ostream& os, const modint& m) { return os << m.val(); }
constexpr u32 val() const { return m_val; }
template<typename I>
constexpr modint pow(I n) const
{
return powerInt(*this, n);
}
constexpr modint inv() const { return inverse<i32>(m_val, mod()); }
static modint sinv(u32 n)
{
auto& is = sinvRef();
for (u32 i = (u32)is.size(); i <= n; i++) { is.push_back(-is[mod() % i] * (mod() / i)); }
return is[n];
}
static modint fact(u32 n)
{
auto& fs = factRef();
for (u32 i = (u32)fs.size(); i <= n; i++) { fs.push_back(fs.back() * i); }
return fs[n];
}
static modint ifact(u32 n)
{
auto& ifs = ifactRef();
for (u32 i = (u32)ifs.size(); i <= n; i++) { ifs.push_back(ifs.back() * sinv(i)); }
return ifs[n];
}
static modint perm(int n, int k) { return k > n or k < 0 ? modint{0} : fact(n) * ifact(n - k); }
static modint comb(int n, int k)
{
return k > n or k < 0 ? modint{0} : fact(n) * ifact(n - k) * ifact(k);
}
private:
static Vec<modint>& sinvRef()
{
static Vec<modint> is{1, 1};
return is;
}
static Vec<modint>& factRef()
{
static Vec<modint> fs{1, 1};
return fs;
}
static Vec<modint>& ifactRef()
{
static Vec<modint> ifs{1, 1};
return ifs;
}
static constexpr u32 norm(u32 x) { return x < mod() ? x : x - mod(); }
static constexpr u32 normll(i64 x) { return norm(u32(x % (i64)mod() + (i64)mod())); }
u32 m_val;
};
using modint_1000000007 = modint<1000000007, 5, 1>;
using modint_998244353 = modint<998244353, 3, 23>;
template<int id>
using modint_dynamic = modint<0, 0, id>;
template<typename T = int>
class Graph
{
struct Edge
{
Edge() = default;
Edge(int i, int t, T c) : id{i}, to{t}, cost{c} {}
int id;
int to;
T cost;
operator int() const { return to; }
};
public:
Graph(int n) : m_v{n}, m_edges(n) {}
void addEdge(int u, int v, bool bi = false)
{
assert(0 <= u and u < m_v);
assert(0 <= v and v < m_v);
m_edges[u].emplace_back(m_e, v, 1);
if (bi) { m_edges[v].emplace_back(m_e, u, 1); }
m_e++;
}
void addEdge(int u, int v, const T& c, bool bi = false)
{
assert(0 <= u and u < m_v);
assert(0 <= v and v < m_v);
m_edges[u].emplace_back(m_e, v, c);
if (bi) { m_edges[v].emplace_back(m_e, u, c); }
m_e++;
}
const Vec<Edge>& operator[](const int u) const
{
assert(0 <= u and u < m_v);
return m_edges[u];
}
Vec<Edge>& operator[](const int u)
{
assert(0 <= u and u < m_v);
return m_edges[u];
}
int v() const { return m_v; }
int e() const { return m_e; }
friend Ostream& operator<<(Ostream& os, const Graph& g)
{
for (int u : rep(g.v())) {
for (const auto& [id, v, c] : g[u]) {
os << "[" << id << "]: ";
os << u << "->" << v << "(" << c << ")\n";
}
}
return os;
}
Vec<T> sizes(int root = 0) const
{
const int N = v();
assert(0 <= root and root < N);
Vec<T> ss(N, 1);
Fix([&](auto dfs, int u, int p) -> void {
for ([[maybe_unused]] const auto& [_temp_name_1, v, c] : m_edges[u]) {
if (v == p) { continue; }
dfs(v, u);
ss[u] += ss[v];
}
})(root, -1);
return ss;
}
Vec<T> depths(int root = 0) const
{
const int N = v();
assert(0 <= root and root < N);
Vec<T> ds(N, 0);
Fix([&](auto dfs, int u, int p) -> void {
for ([[maybe_unused]] const auto& [_temp_name_2, v, c] : m_edges[u]) {
if (v == p) { continue; }
ds[v] = ds[u] + c;
dfs(v, u);
}
})(root, -1);
return ds;
}
Vec<int> parents(int root = 0) const
{
const int N = v();
assert(0 <= root and root < N);
Vec<int> ps(N, -1);
Fix([&](auto dfs, int u, int p) -> void {
for ([[maybe_unused]] const auto& [_temp_name_3, v, c] : m_edges[u]) {
if (v == p) { continue; }
ps[v] = u;
dfs(v, u);
}
})(root, -1);
return ps;
}
private:
int m_v;
int m_e = 0;
Vec<Vec<Edge>> m_edges;
};
int main()
{
using mint = modint_998244353;
const auto [N, D, R] = in.tup<int, int, int>();
mint ans = 0;
Vec<mint> fs(D + 1, 0);
fs[1] = -1;
for (int K : irange(R + 1, D + 1)) {
fs[K] = mint::comb(K - 2, R - 1) * (R % 2 == 0 ? 1 : -1);
}
for (int K : irange(1, D + 1)) {
fs[K] *= mint::comb(N, K) * (K % 2 == 0 ? 1 : -1);
}
Vec<bool> isps(D + 1, true);
isps[0] = isps[1] = false;
for (int p : irange(2, D + 1)) {
if (not isps[p]) {
continue;
}
for (int q : irange(p + p, D + 1, p)) {
isps[q] = false;
}
for (int x : irange(1, D / p + 1)) {
fs[x * p] += fs[x];
}
}
for (int P : irange(1, D + 1)) {
ans += fs[P] * mint::comb(N + D - 1 - P, N - 1);
}
ans /= mint::comb(D + N - 1, N - 1);
ans += R;
out.ln(ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
input:
2 3 1
output:
499122180
result:
ok 1 number(s): "499122180"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 3 2
output:
698771052
result:
ok 1 number(s): "698771052"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
5 10 3
output:
176512750
result:
ok 1 number(s): "176512750"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
5 4 3
output:
71303175
result:
ok 1 number(s): "71303175"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
37 47 12
output:
962577218
result:
ok 1 number(s): "962577218"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
29 50 26
output:
175627840
result:
ok 1 number(s): "175627840"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
298 498 221
output:
765832019
result:
ok 1 number(s): "765832019"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
497 456 243
output:
414028615
result:
ok 1 number(s): "414028615"
Test #9:
score: 0
Accepted
time: 0ms
memory: 4784kb
input:
114514 1926 817
output:
691374994
result:
ok 1 number(s): "691374994"
Test #10:
score: 0
Accepted
time: 27ms
memory: 31088kb
input:
1919810 1554 1999
output:
3553
result:
ok 1 number(s): "3553"
Test #11:
score: 0
Accepted
time: 24ms
memory: 32364kb
input:
1926817 1514 1001
output:
685086550
result:
ok 1 number(s): "685086550"
Test #12:
score: 0
Accepted
time: 20ms
memory: 29032kb
input:
1432132 1425 1425
output:
2850
result:
ok 1 number(s): "2850"
Test #13:
score: 0
Accepted
time: 968ms
memory: 315736kb
input:
14999999 15000000 14999999
output:
29999999
result:
ok 1 number(s): "29999999"
Test #14:
score: 0
Accepted
time: 6ms
memory: 5536kb
input:
98765 99654 85647
output:
815183913
result:
ok 1 number(s): "815183913"
Test #15:
score: 0
Accepted
time: 6ms
memory: 5372kb
input:
99999 100000 99998
output:
832290200
result:
ok 1 number(s): "832290200"
Test #16:
score: 0
Accepted
time: 5ms
memory: 4936kb
input:
1541 99998 725
output:
463021366
result:
ok 1 number(s): "463021366"
Test #17:
score: 0
Accepted
time: 63ms
memory: 24900kb
input:
985438 998756 101254
output:
671487608
result:
ok 1 number(s): "671487608"
Test #18:
score: 0
Accepted
time: 46ms
memory: 25376kb
input:
998654 999856 2
output:
92085960
result:
ok 1 number(s): "92085960"
Test #19:
score: 0
Accepted
time: 56ms
memory: 20312kb
input:
45876 1000000 13
output:
208089291
result:
ok 1 number(s): "208089291"
Test #20:
score: 0
Accepted
time: 1160ms
memory: 314880kb
input:
15000000 14999999 514
output:
143843956
result:
ok 1 number(s): "143843956"
Test #21:
score: 0
Accepted
time: 1212ms
memory: 315908kb
input:
14985345 14999998 145124
output:
785676527
result:
ok 1 number(s): "785676527"
Test #22:
score: 0
Accepted
time: 1189ms
memory: 315244kb
input:
14855345 14993298 1451424
output:
779861797
result:
ok 1 number(s): "779861797"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
1 1 1
output:
2
result:
ok 1 number(s): "2"
Test #24:
score: 0
Accepted
time: 979ms
memory: 312928kb
input:
15000000 15000000 15000000
output:
30000000
result:
ok 1 number(s): "30000000"
Extra Test:
score: 0
Extra Test Passed