题目链接:http://codeforces.com/contest/837/problem/F

题意:如题QAQ

解法:参考题解博客:http://www.cnblogs.com/FxxL/p/7282909.html

     由于新生成的m+1个数列第一个肯定为0,所以可以忽略掉,当作每次新生成的数列只拥有m个元素

     来枚举一个例子,可以发现规律。

当a[] = {1,0,0,0,0}时,手动推出的矩阵如下:

可以发现对于这个矩阵显然是满足杨辉三角的,我们二分出一个值后可以直接利用组合数来计算出当前的答案,然后check

#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
typedef long long LL;
LL n,k,a[maxn]; bool check(LL mid){
double sum=0;
LL x,y,p,q;
for(LL t=0; t<n; t++){
if(a[t]==0) continue;
x=mid; y=(n-1)-t;
p=x-1; q=p+y;
p = min(q-p, p);
double tmp = a[t];
for(LL i=q, j=p; j>=1; j--,i--){
tmp = tmp*i/j;
if(tmp>=k) return true;
}
sum += tmp;
if(sum>=k) return true;
}
return false;
}
int main()
{
cin>>n>>k;
for(int i=0; i<n; i++){
cin>>a[i];
if(a[i]>=k){
printf("0\n");
return 0;
}
}
LL l=0,r=k,ans;
while(l<=r){
LL mid=(l+r)/2;
if(check(mid)) ans=mid,r=mid-1;
else l=mid+1;
}
bool ok = check(2);
if(ans==0) ans++;
cout<<ans<<endl;
return 0;
}

Educational Codeforces Round 26 F. Prefix Sums 二分,组合数的更多相关文章

  1. CodeForces 837F - Prefix Sums | Educational Codeforces Round 26

    按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...

  2. Educational Codeforces Round 26

    Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...

  3. CodeForces - 837E - Vasya's Function | Educational Codeforces Round 26

    /* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f( ...

  4. Educational Codeforces Round 40 F. Runner's Problem

    Educational Codeforces Round 40 F. Runner's Problem 题意: 给一个$ 3 * m \(的矩阵,问从\)(2,1)$ 出发 走到 \((2,m)\) ...

  5. CodeForces 837D - Round Subset | Educational Codeforces Round 26

    /* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...

  6. Educational Codeforces Round 26 [ D. Round Subset ] [ E. Vasya's Function ] [ F. Prefix Sums ]

    PROBLEM D - Round Subset 题 OvO http://codeforces.com/contest/837/problem/D 837D 解 DP, dp[i][j]代表已经选择 ...

  7. Educational Codeforces Round 21 D.Array Division(二分)

    D. Array Division time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  8. Educational Codeforces Round 11 C. Hard Process 二分

    C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...

  9. Educational Codeforces Round 61 F 思维 + 区间dp

    https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同 ...

随机推荐

  1. Socket_SSH-3(粘包)

    粘包:两次数据粘到一起了.在Windows中基本看不出来效果. 服务器端的配置: import socket,os,time server=socket.socket() server.bind((' ...

  2. CentOS 文件及目录等

    1.在linux中一切皆是文件,只是类型不同,通过ls -l看到的一个字母表示文件的类型 -:普通文件. d:目录文件. l:链接文件. b:块设备文件. c:字符设备文件. p:管道文件. 2.文件 ...

  3. [BZOJ5303] [HAOI2018] 反色游戏

    题目链接 LOJ:https://loj.ac/problem/2524 BZOJ:https://lydsy.com/JudgeOnline/problem.php?id=5303 洛谷:https ...

  4. [HNOI2010]合唱队 区间DP

    ---题面--- 题解: 偶然翻到这道题,,,就写了. 观察到一个数被插在哪里只受前一个数的影响,如果明确了前一个数是哪个,那么我们就可以确定大小关系,就可以知道当前这个数插在哪里,而上一个插入的数就 ...

  5. POJ2142:The Balance——题解

    http://poj.org/problem?id=2142 题目大意:有一天平和两种数量无限的砝码(重为a和b),天平左右都可以放砝码,称质量为c的物品,要求:放置的砝码数量尽量少:当砝码数量相同时 ...

  6. BZOJ3195:[JXOI2012]奇怪的道路——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=3195 Description 小宇从历史书上了解到一个古老的文明.这个文明在各个方面高度发达,交通方 ...

  7. bzoj2761: [JLOI2011]不重复数字(hash)

    题目大意:给出N个数,要求把其中重复的去掉,只保留第一次出现的数.例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4. ...

  8. 总结:Bias(偏差),Error(误差),Variance(方差)及CV(交叉验证)

    犀利的开头 在机器学习中,我们用训练数据集去训练(学习)一个model(模型),通常的做法是定义一个Loss function(误差函数),通过将这个Loss(或者叫error)的最小化过程,来提高模 ...

  9. [转载][mysql]mysql字符集干货

    源地址:http://www.blogjava.net/zyskm/archive/2013/04/09/361888.html 字符集的概念大家都清楚,校对规则很多人不了解,一般数据库开发中也用不到 ...

  10. POJ 3984 BFS

    迷宫问题 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20665   Accepted: 12100 Descriptio ...