map<longdouble, int> mp; int cur = 0; for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; if (a == 0 && b == 0) { continue; } longdouble s = atan2l(a, -b); // 必须 long double longdouble t = atan2l(-a, b); mp[s]++; mp[t]--; if (s > t) { cur++; } }
int ans = cur; for (auto [_, delta] : mp) { cur += delta; ans = max(ans, cur); } cout << ans << '\n'; }
structDisjointSets { vector<int> f; int tot; DisjointSets(int n) : f(n, -1), tot(n) {} intfind(int x){ return f[x] < 0 ? x : f[x] = find(f[x]); } intsize(int x){ return -f[find(x)]; } boolsame(int x, int y){ returnfind(x) == find(y); } booluno(int x, int y){ x = find(x), y = find(y); if (x == y) returnfalse; return f[x] += f[y], f[y] = x, tot--; } };
voidsolve(){ int n, q; cin >> n >> q;
vector dsu(1 << 12, DisjointSets(n));
ll ans = 0; while (q--) { char opt; cin >> opt; int x, y; cin >> x >> y; x--; y--; if (opt == '+') { int w; cin >> w; auto add = [&](thisauto&& add, int w) -> void { if (dsu[w].uno(x, y)) { for (int bit = 0; bit < 12; bit++) { if (w >> bit & 1) { add(w ^ (1U << bit)); } } } }; add(w); } else { int res = 0; for (int bit = 11; bit >= 0; bit--) { if (dsu[res | (1U << bit)].same(x, y)) { res |= (1U << bit); } } if (!dsu[0].same(x, y)) { res = -1; } ans += res; } } cout << ans << endl; }
int q; cin >> q; while (q--) { ll t; cin >> t; int lo = 0, hi = n; while (lo < hi) { int mid = lo + hi >> 1; if (v[mid] - l[mid] * t >= 0) { lo = mid + 1; } else { hi = mid; } } cout << (prev[lo] - t * prel[lo]) << " "; } cout << '\n'; }
// 遍历每一个可能的确知预算状态 i for (int i = 0; i <= m - b; i++) { // i + b : 确定的费用转移 // 如果 i + b > m,循环条件限制了我们不会进入这里,保证了最坏情况不超标 // ndp[i + b][0] : 第 k 天花费 i + b 且当前状态为 0 的最大期望 chmax(ndp[i + b][0], a + // 今天的确定性收益 p * dp[i][1] + // 概率转移:如果 A 付钱,未来(第 k+1 天以后)基于状态 1 的期望 q * dp[i][2] // 概率转移:如果 B 付钱,未来(第 k+1 天以后)基于状态 2 的期望 ); }
vector<array<int, 6>> v(n); for (auto& [a, b, c, d, e, x] : v) { cin >> a >> b >> c >> d >> e >> x; } ranges::reverse(v);
vector<array<double, 4>> dp(m + 1); for (auto& [a, b, c, d, e, x] : v) { vector<array<double, 4>> ndp(m + 1); for (int i = 0; i <= m; i++) { ndp[i].fill(-inf); }
double p = 0.01L * x; double q = 1 - p;
// cafeteria for (int i = 0; i <= m - b; i++) { chmax(ndp[i + b][0], a + p * dp[i][1] + q * dp[i][2]); chmax(ndp[i + b][1], a + p * dp[i][1] + q * dp[i][3]); chmax(ndp[i + b][2], a + p * dp[i][3] + q * dp[i][2]); chmax(ndp[i + b][3], a + p * dp[i][3] + q * dp[i][3]); }
// go out and taxi fare for (int i = 0; i <= m - d - e; i++) { chmax(ndp[i + d + e][3], c + dp[i][0]); }
// go out and no taxi fare for (int i = 0; i <= m - d; i++) { chmax(ndp[i + d][0], c + p * dp[i][1] + q * dp[i][2]); chmax(ndp[i + d][1], c + p * dp[i][1] + q * dp[i][3]); chmax(ndp[i + d][2], c + p * dp[i][3] + q * dp[i][2]); }
dp = ndp; }
double res = -inf; for (int i = 0; i <= m; i++) { chmax(res, dp[i][0]); } if (res < 0) { cout << -1 << endl; } else { cout << fixed << setprecision(12) << res << endl; }