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. sql server 查询某个时间段共有多少周及每周的日期段

    sql 语句 as wknum,dateadd(wk,number,'2017-01-01') as firstday, (,, then '2017-12-31' ,,'2017-01-01')) ...

  2. android greenDao使用

    github:https://github.com/greenrobot/greenDAO 基本使用:https://toutiao.io/posts/yg1kyu/preview https://b ...

  3. SpringAOP深入学习

    ----------------------Spring AOP介绍------------------ 1.编程范式概念 面向过程编程:C 面向对象编程:c++,Java 函数式编程 事件驱动编程: ...

  4. libSVM在matlab下的使用安装

    1) 从LIBSVM的官网http://www.csie.ntu.edu.tw/~cjlin/libsvm/上下载最新版本的LIBSVM,当前版本为libsvm-3.18.zip 2) 解压压缩包到电 ...

  5. SpringBoot使用外置的Servlet容器

    SpringBoot默认使用嵌入式的Servlet容器,应用打包成可执行的jar包 优点:简单.便携 缺点:默认不支持jsp,优化定制比较复杂(使用定制器serverProperties.自定义Emb ...

  6. 001_ansible通过堡垒机登录

    一. 之前一直通过跳板机登录线上服务器,ssh可以的,如下图所示 vim ~/.ssh/config ssh xx.xx.xx.xx线上服务器是可以的,但是ansible执行显示目标主机不可达,其实a ...

  7. certificate expired

    最近在测试802.1x,测试过程中,radius服务器端一直显示如下错误: (5)   authenticate {(5) eap: Expiring EAP session with state 0 ...

  8. 14-jQuery补充

    jquery内容补充 jquery除了咱们上面讲解的常用知识点之外,还有jquery 插件.jqueryUI知识点 jqueryUI 官网: https://jqueryui.com/ jqueryU ...

  9. [Java]求文件大小并保留两位小数(文件大小是一个长整型数单位是Byte)

    前言 为了获得一堆apk的大小,并与人类友好方式显示.本来是打算用以下方法,到时不能具体到保留两位小数. org.apache.commons.io.FileUtils.byteCountToDisp ...

  10. linux unzip 中文乱码解决方法

    引自:https://blog.csdn.net/abyjun/article/details/48344379 unzip -O CP936 xxx.zip (用GBK, GB18030也可以)