思路:

很奇怪的结论题,不好想。参考了http://codeforces.com/blog/entry/59623

实现:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x7f7f7f7f;
ll n, H;
bool check(ll m)
{
ll tmp = min(m, H);
return m * m - tmp * (tmp - ) / <= n;
}
ll solve(ll n, ll H)
{
ll l = , r = INF, ans = -;
while (l <= r)
{
ll m = l + r >> ;
if (check(m))
{
ans = m;
l = m + ;
}
else r = m - ;
}
return ans;
}
int main()
{
while (cin >> n >> H)
{
ll k = solve(n, H);
ll t = min(k, H);
ll ans = * k - - t;
ll rem = n - (k * k - t * (t - ) / );
ans += (rem + k - ) / k;
cout << ans + << endl;
}
return ;
}

CF985D Sand Fortress的更多相关文章

  1. Codeforces 985 D - Sand Fortress

    D - Sand Fortress 思路: 二分 有以下两种构造, 分别二分取个最小. 代码: #include<bits/stdc++.h> using namespace std; # ...

  2. codeforces 985 D. Sand Fortress(二分+思维)

    Sand Fortress time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  3. CodeForces 985D Sand Fortress

    Description You are going to the beach with the idea to build the greatest sand castle ever in your ...

  4. Educational Codeforces Round 44 (Rated for Div. 2)

    题目链接:https://codeforces.com/contest/985 ’A.Chess Placing 题意:给了一维的一个棋盘,共有n(n必为偶数)个格子.棋盘上是黑白相间的.现在棋盘上有 ...

  5. Codeforces 985 最短水桶分配 沙堆构造 贪心单调对列

    A B /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a, ...

  6. bzoj 3399: [Usaco2009 Mar]Sand Castle城堡

    3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec  Memory Limit: 128 MB Description 约翰用沙子建了一座城堡.正 ...

  7. BZOJ3399: [Usaco2009 Mar]Sand Castle城堡

    3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 22  Solved: 17[Sub ...

  8. 3399: [Usaco2009 Mar]Sand Castle城堡

    3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 37  Solved: 32[Sub ...

  9. gym 101081 E. Polish Fortress 几何

    E. Polish Fortress time limit per test 2.0 s memory limit per test 256 MB input standard input outpu ...

随机推荐

  1. Delphi通过POST传递参数给PHP

    Delphi代码 ******************************************************************************************* ...

  2. ie的兼容方法,条件注释的方法

    1.终极方法:条件注释 <!--[if lte IE 6]> 这段文字仅显示在 IE6及IE6以下版本. <![endif]--> <!--[if gte IE 6]&g ...

  3. ADB运行框架原理解析【转】

    本文转载自:http://blog.csdn.net/wlwl0071986/article/details/50935496 一.adb守护进程的初始化 源码路径:~/system/core/adb ...

  4. kafka 查询 SQL Query

    . SELECT COUNT(*) FROM wiseweb_crawler_foreignmedias WHERE site_id= AND (gathertime BETWEEN '2017-05 ...

  5. emacs环境配置

    Cscope: 首先官网上下载cscope的源码包,解压进入,按照INSTALL的说明: ./configure make make install 但是在make时报如下错误:fatal error ...

  6. BZOJ_3049_[Usaco2013 Jan]Island Travels _状压DP+BFS

    BZOJ_3049_[Usaco2013 Jan]Island Travels _状压DP+BFS Description Farmer John has taken the cows to a va ...

  7. 「SHOI2007」「Codevs2341」 善意的投票(最小割

    2341 善意的投票 2007年省队选拔赛上海市队选拔赛 时间限制: 5 s 空间限制: 128000 KB 题目等级 : 大师 Master   题目描述 Description 幼儿园里有n个小朋 ...

  8. kubeadm安装Kubernetes13.1集群-三

    环境: master: 192.168.3.100 node01: 192.168.3.101 node02: 192.168.3.102 关闭所有主机防火墙,selinux: 配置主机互信: mas ...

  9. 关于Android ListView组件中android:drawSelectorOnTop含义(转载)

    转自:http://yangguangfu.iteye.com/blog/902559 When set to true, the selector will be drawn over the se ...

  10. Thrift 使用TNonblockingServer模型时调用PosixThreadFactory出错。

    Thrift 使用TNonblockingServer模型时调用PosixThreadFactory出错.   我定位到shared_ptr<PosixThreadFactory> thr ...