AtCoder Regular Contest 118

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;
}
上一篇:manacher算法


下一篇:信息学奥赛一本通 1147:最高分数的学生姓名 | OpenJudge NOI 1.9 02