Codeforces 830C Bamboo Partition (看题解)

Posted cjlhy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces 830C Bamboo Partition (看题解)相关的知识,希望对你有一定的参考价值。

Bamboo Partition

列公式, 整除分块, 想不到, 好菜啊。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long

using namespace std;

const int N = 100 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double PI = acos(-1);

LL n, k, a[N], b[10000007], tar, tot;

int main() {
    scanf("%lld%lld", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        tar += a[i];
        a[i]--;
    }
    tar += k;
    for(int i = 1; i <= n; i++) {
        for(int j = 1, k; j < a[i]; j = k + 1) {
            k = a[i] / (a[i] / j);
            b[tot++] = j;
        }
        b[tot++] = a[i] + 1;
    }
    sort(b, b + tot);
    tot = unique(b, b + tot) - b;
    for(int i = tot - 1; i >= 0; i--) {
        LL d = b[i], val = 0;
        for(int i = 1; i <= n; i++)
            val += d * (a[i] / d);
        if(n * d + val <= tar) {
            val = 0;
            for(int i = 1; i <= n; i++) val += a[i] / d;
            printf("%lld
", tar / (val + n));
            return 0;
        }
    }
    return 0;
}

/*
*/

 

以上是关于Codeforces 830C Bamboo Partition (看题解)的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces 588

从 Bamboo 构建开始 Bamboo 部署

SoapUI/Maven/Bamboo:Bamboo 作业中的异常

如何编写一个从另一个 Bamboo 计划获取内部版本号的新 Bamboo 计划?

Codeforces 919 E Congruence Equation

Linux中bamboo服务端安装配置