voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { int k, x, a; cin >> k >> x >> a; int ca = a, lose = 0; bool flag = true; for (int i = 0; i < x; ++i) { int cur = (lose + k - 1) / (k - 1); if (ca < cur) { flag = false; break; } ca -= cur; lose += cur; } if (ca * k <= a) flag = false; cout << (flag ? "YES" : "NO") << endl; } }
voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { int n; cin >> n; constexprint mod = 998244353; vector<pair<int, int>> edges((n - 1) * 2); vector<int> head(n + 1, -1); for (int i = 0; i < n - 1; ++i) { int u, v; cin >> u >> v; edges[i << 1] = {v, head[u]}; edges[i << 1 | 1] = {u, head[v]}; head[u] = i << 1; head[v] = i << 1 | 1; }
function<pair<int, int>(int, int)> dfs = [&](int u, int p) { int a = 1, b = 0; for (int e = head[u]; ~e; e = edges[e].second) { if (edges[e].first == p) continue; auto [na, nb] = dfs(edges[e].first, u); a = (a * (1 + na)) % mod; b = (b + na + nb) % mod; }
returnmake_pair(a, b); };
auto [a, b] = dfs(1, 0); cout << (a + b + 1) % mod << endl; } }