标签:time clu reg inline for 个数 max tco lag
int main() {
IOS; ll k, c; cin >> n >> k;
c = (100 * k - 1) / n + 1;
cout << (n + 100) * c / 100 - 1;
return 0;
}
最小最大值, 明显二分, 处理分数, 直接两边同乘\(n \times m\)
ll a[N], mx[N], mi[N], b[N], c[N];
bool check(ll mid) {
rep (i, 1, k) {
ll cur = a[i] + mid;
mx[i] = min((a[i] + mid) / n, (ll)m) + mx[i - 1];
if (a[i] <= mid) mi[i] = mi[i - 1];
else mi[i] = max(0ll, (a[i] - mid - 1) / n + 1) + mi[i - 1];
}
return mi[k] <= m && mx[k] >= m;
}
int main() {
IOS; cin >> k >> n >> m;
rep (i, 1, k) cin >> a[i], a[i] *= m;
ll l = 0, r = 1e18;
while (l < r) {
ll mid = l + r >> 1;
if (check(mid)) r = mid, memcpy(b, mx, sizeof b), memcpy(c, mi, sizeof c);
else l = mid + 1;
}
per (i, k, 1) {
a[i] = min(m - c[i - 1], b[i] - b[i - 1]);
m -= a[i];
}
rep (i, 1, k) cout << a[i] << ‘ ‘;
return 0;
}
不能超\(1000\)
说白了用\(k\)个质数, 每个数含有\(k - 1\)个质数就行
又因为\(a_i \neq a_j, i \neq j\) 故只能改变质数的指数了
又不超\(1000\), 那就直接选\(2, 3, 5\), 然后不断改变\(2, 3, 5\) 的指数就行
你多乘个质数\(7\) 不如乘 \(2, 3, 5\) 这样不会超\(1000\)
int main() {
IOS; cin>>n;
cout<< "6 10 15";
for (int i = 3, j = 16; i < n; ++j) if (!(j % 6) || !(j % 10) || !(j % 15))
cout << ‘ ‘ << j, ++i;
return 0;
}
标签:time clu reg inline for 个数 max tco lag
原文地址:https://www.cnblogs.com/2aptx4869/p/14750760.html