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 = + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); LL n, k, a[N], b[], tar, tot; int main() {
scanf("%lld%lld", &n, &k);
for(int i = ; i <= n; i++) {
scanf("%lld", &a[i]);
tar += a[i];
a[i]--;
}
tar += k;
for(int i = ; i <= n; i++) {
for(int j = , k; j < a[i]; j = k + ) {
k = a[i] / (a[i] / j);
b[tot++] = j;
}
b[tot++] = a[i] + ;
}
sort(b, b + tot);
tot = unique(b, b + tot) - b;
for(int i = tot - ; i >= ; i--) {
LL d = b[i], val = ;
for(int i = ; i <= n; i++)
val += d * (a[i] / d);
if(n * d + val <= tar) {
val = ;
for(int i = ; i <= n; i++) val += a[i] / d;
printf("%lld\n", tar / (val + n));
return ;
}
}
return ;
} /*
*/

Codeforces 830C Bamboo Partition (看题解)的更多相关文章

  1. Codeforces 830C Bamboo Partition 其他

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF830C.html 题解 把问题转化成求最大的 $d$ ,满足$$\sum_{1\leq i \leq n}( ...

  2. Codeforces 269C Flawed Flow (看题解)

    我好菜啊啊啊.. 循环以下操作 1.从队列中取出一个顶点, 把哪些没有用过的边全部用当前方向. 2.看有没有点的入度和 == 出度和, 如果有将当前的点加入队列. 现在有一个问题就是, 有没有可能队列 ...

  3. Codeforces 436E Cardboard Box (看题解)

    Cardboard Box 贪了个半天贪不对, 我发现我根本就不会贪心. 我们先按b排序, 然后枚举选两颗心的b的最大值, 在这个之前的肯定都要选一个, 因为前面的要是一个都没选的话, 你可以把当前选 ...

  4. Codeforces 1045C Hyperspace Highways (看题解) 圆方树

    学了一下圆方树, 好神奇的东西呀. #include<bits/stdc++.h> #define LL long long #define fi first #define se sec ...

  5. Codeforces 1137D Cooperative Game (看题解)

    Cooperative Game 智商题, 感觉不太能推出来, 虽然看看证明过程是对的. #include<bits/stdc++.h> #define LL long long #def ...

  6. Codeforces 875F Royal Questions (看题解)

    我还以为是什么板子题呢... 我们把儿子当做点, 公主当做边, 然后就是求边权值最大基环树森林. #include<bits/stdc++.h> #define LL long long ...

  7. Codeforces 983C Elevator dp (看题解)

    Elevator 怎么今天写啥题都不会写啊, 我是傻了吗.. 把电梯里面四个人的目标点当作状态, 然后暴力转移. #include<bits/stdc++.h> #define LL lo ...

  8. Codeforces 924D Contact ATC (看题解)

    Contact ATC 我跑去列方程, 然后就gg了... 我们计每个飞机最早到达时间为L[ i ], 最晚到达时间为R[ i ], 对于面对面飞行的一对飞机, 只要他们的时间有交集则必定满足条件. ...

  9. Codeforces 750E New Year and Old Subsequence 线段树 + dp (看题解)

    New Year and Old Subsequence 第一感觉是离线之后分治求dp, 但是感觉如果要把左边的dp值和右边的dp值合起来, 感觉很麻烦而且时间复杂度不怎么对.. 然后就gun取看题解 ...

随机推荐

  1. Windows 与 Linux下关于端口不能访问的问题

    自己写的一个HTTP文件服务器,在端口 50000上监听HTTP连接请求,在Eclipse里面将程序正常地启动之后,能够在自己的机器上(Eclipse启动该程序的机器上)访问 50000端口,即Fil ...

  2. DotNetBar滚动条的疑似BUG

    1.重现过程,在winform窗体上拖一个VScrollBarAdv 2.Button里点击跟踪代码 3.Value居然是-5,,而不是0,这是直接赋值,不是手动拖的呀. 4.解决办法,将LargeC ...

  3. 在安卓上用Termux安装sqlmap

    1.打开Termux执行以下命令 apt update apt install git apt install python2 // 安装sqlmap运行环境 2.从github上下载sqlmap , ...

  4. Unity3d跨平台原理

    知乎的一个提问:unity3d跨平台原理 一些资料: IL IL是.NET框架中中间语言(Intermediate Language)的缩写.使用.NET框架提供的编译器可以直接将源程序编译为.exe ...

  5. Python装饰器实现异步回调

    def callback(func): def inner(obj, *args, **kwargs): res = func(obj, *args, **kwargs) if kwargs.get( ...

  6. SpringBoot2.x整合Redis实战 4节课

    1.分布式缓存Redis介绍      简介:讲解为什么要用缓存和介绍什么是Redis,新手练习工具 1.redis官网 https://redis.io/download          2.新手 ...

  7. maven阿里云镜像

    <mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorO ...

  8. ubuntu14.04 安装 openssh-server

    ubuntu自带的有openssh-client,所以可以通过 ssh username@host 来远程连接linux 可是要想通过ssh被连接,ubuntu系统需要有openssh-server, ...

  9. SpringBoot定制错误的Json数据

    (1)自定义异常处理&返回定制Json数据 @ControllerAdvice public class MyExceptionHandler { @ResponseBody @Excepti ...

  10. Ajax+json+jquery实现无限瀑布流布局

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...