题目链接:http://codeforces.com/problemset/problem/760/B

题意:n个床位,m个枕头,第k个位置最多有多少个枕头,其中相邻之间的差<=1;

第k个位置最大,那么两边只能是-1,-2,-3下走。

二分查找。

 #include <bits/stdc++.h>

 using namespace std;

 long long n,m,k;

 int Slove(long long mid) {
long long sum = ;
if(k>=mid)
{
sum+=(+mid)*mid/;
sum+=(k-mid);
}
if(k<mid) {
sum+=((mid-k+)+mid)*k/;
} if(k+(mid-)<=n) {
sum+=(+mid)*mid/;
sum+=n-(k+(mid-));
} if(k+(mid-)>n) {
sum+=(mid+(mid-n+k))*(n-k+)/;
}
if(sum-mid<=m) return ;
else return ;
} int main()
{
//scanf("%d%d%d",&n,&m,&k);
cin>>n>>m>>k;
long long ans = ;
long long l = ;
long long r = m;
while(l<=r) { long long mid = (l+r)/;
if(Slove(mid)==) {
ans = mid;
l = mid+;
}
else r = mid-;
}
cout<<ans<<endl;
return ;
}

Codeforces 760B Frodo and pillows的更多相关文章

  1. cf 760B.Frodo and pillows

    二分,判断条件就是最小情况(设当前k位取x)比剩余值(m-x)要小.(貌似又做麻烦了2333) #include<bits/stdc++.h> #define LL long long # ...

  2. Codefroces 760 B. Frodo and pillows

    B. Frodo and pillows time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. 【codeforces 760B】Frodo and pillows

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. Codeforces 760B:Frodo and pillows(二分)

    http://codeforces.com/problemset/problem/760/B 题意:有n张床m个枕头,每张床可以有多个枕头,但是相邻的床的枕头数相差不能超过1,问第k张床最多能拥有的枕 ...

  5. Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)A 水 B 二分 C并查集

    A. Petr and a calendar time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. Codeforces Round #393 (Div. 2)

    A. Petr and a calendar time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

  7. CodeForces760B

    B. Frodo and pillows time limit per test:1 second memory limit per test:256 megabytes input:standard ...

  8. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  9. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

随机推荐

  1. sql server 字符串转table

    -- ============================================= -- Author: gengc -- Create date: <2012-12-29> ...

  2. 并行执行hive脚本

    ### 模板脚本存放路径(无需修改) cd /tmp/fix_data/tmp_wjj_20180322_01 ### 脚本名称 script=tmp_wjj_20180322_01 ### 开始日期 ...

  3. Unable to instantiate receiver xxx.receiver.NetworkReceiver异常

    Unable to instantiate xxxreceiver.NetworkReceiver: 这个异常是之前版本有NetworkReceiver(监听网络变化的),新的版本删除了Network ...

  4. KEIL的多工程多目标

    https://blog.csdn.net/ybhuangfugui/article/details/51655502 https://mp.weixin.qq.com/s/CSUa4zegzz8JW ...

  5. 性能测试工具Jmeter08-Jmeter断言(检查点)

    断言是在请求的返回层面增加一层判断机制.因为请求成功了,并不代表结果一定正确,因此需要检测机制提高测试准确性. 下面介绍常用的jmeter三种断言 1.响应断言 例如: 模式匹配规则 2.Size A ...

  6. python3+Appium自动化11-data数据封装之python读取csv文件

    使用背景 实际项目中,我们的测试数据可能存储在一个数据文件中,如txt.excel.csv文件类型.我们可以封装一些方法来读取文件中的数据来实现数据驱动 enumerate()简介 enumerate ...

  7. script脚本中写不写$(document).ready(function() {});的区别

    $(document).ready() 里的代码是在页面内容都加载完才执行的,如果把代码直接写到script标签里,当页面加载完这个script标签就会执行里边的代码了,此时如果你标签里执行的代码调用 ...

  8. & 和nohup使用

    " & "的使用  将工作丢到背景(这里指的背景并非是系统的背景,指的是在终端模式下,可以避免ctrl+c中断的一个情景)中去执行(但是如果终端关闭时,程序也就退出了,这时 ...

  9. intellijidea课程 intellijidea神器使用技巧 3-3 postfix

    Ctrl shift A ==> postfix completion 调出postfix 方法体中   ==> for   100.fori    ==>enter for循环10 ...

  10. jQuery的下拉框应用

    jQuery的下拉框应用 jQuery的下拉框左右选择应用 直接上代码 <!DOCTYPE html> <html> <head> <meta charset ...