#include<bits/stdc++.h> usingnamespace std; constexprint MAXN = 1e4 + 5; structRect { int x, y, a, b; } a[MAXN]; intmain(){ int n, x, y, ans = -1; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y >> a[i].a >> a[i].b; cin >> x >> y; for (int i = 1; i <= n; i++) { int tx = a[i].x + a[i].a, ty = a[i].y + a[i].b; if (x >= a[i].x && x <= tx && y >= a[i].y && y <= ty) ans = i; } cout << ans; return0; }
#include<bits/stdc++.h> usingnamespace std; intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); longlong T, n, k; cin >> T; while (T--) { cin >> n >> k; if (k == 0) { cout << "0\n"; continue; } longlong ans = n * k; for (longlong a = 1; a * a <= n; a++) { longlong b = n / a, c = n - a * b; ans = min(ans, a + b + c * k); } for (longlong b = 1; b * b <= n; b++) { longlong a = n / b, c = n - a * b; ans = min(ans, a + b + c * k); } cout << ans << "\n"; } return0; }
#include<bits/stdc++.h> usingnamespace std; constexprint MAXN = 5e3 + 5, MOD = 80112002; vector<int> G[MAXN]; int indeg[MAXN], cnt[MAXN]; intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, ans = 0; cin >> n >> m; for(int u, v, i = 0; i < m; i++) { cin >> u >> v; indeg[v]++; G[u].push_back(v); } queue<int> Q; for(int i = 1; i <= n; i++) if (indeg[i] == 0) { Q.push(i); cnt[i] = 1; } while (!Q.empty()) { int u = Q.front(); Q.pop(); for(int i : G[u]) { indeg[i]--; cnt[i] = (cnt[i] + cnt[u]) % MOD; if (indeg[i] == 0) Q.push(i); } } for(int i = 1; i <= n; i++) if (G[i].empty()) ans = (ans + cnt[i]) % MOD; cout << ans; }
#include<bits/stdc++.h> usingnamespace std; constexprint MAXN = 5e3 + 5, MOD = 80112002; vector<int> G[MAXN]; int indeg[MAXN], cnt[MAXN]; intdfs(int u){ if (cnt[u]) return cnt[u]; // 已经计算过 if (G[u].empty()) // 顶级消费者,只有自身一条链 return cnt[u] = 1; int res = 0; for (int v : G[u]) // 累加所有后继的路径数 res = (res + dfs(v)) % MOD; return cnt[u] = res; } intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, ans = 0; cin >> n >> m; for(int u, v, i = 0; i < m; i++) { cin >> u >> v; indeg[v]++; G[u].push_back(v); } for(int i = 1; i <= n; i++) if (indeg[i] == 0) ans = (ans + dfs(i)) % MOD; cout << ans; }