码迷,mamicode.com
首页 > 其他好文 > 详细

AtCoder Regular Contest 118

时间:2021-05-24 04:22:14      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:time   clu   reg   inline   for   个数   max   tco   lag   

AtCoder Regular Contest 118

A - Tax Included Price

int main() {
    IOS; ll k, c; cin >> n >> k;
    c = (100 * k - 1) / n + 1;
    cout << (n + 100) * c / 100 - 1;
    return 0;
}

B - Village of M People

最小最大值, 明显二分, 处理分数, 直接两边同乘\(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;
}

C - Coprime Set

不能超\(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;
}

AtCoder Regular Contest 118

标签:time   clu   reg   inline   for   个数   max   tco   lag   

原文地址:https://www.cnblogs.com/2aptx4869/p/14750760.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!