CF985D Sand Fortress
思路:
很奇怪的结论题,不好想。参考了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的更多相关文章
- Codeforces 985 D - Sand Fortress
D - Sand Fortress 思路: 二分 有以下两种构造, 分别二分取个最小. 代码: #include<bits/stdc++.h> using namespace std; # ...
- codeforces 985 D. Sand Fortress(二分+思维)
Sand Fortress time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- CodeForces 985D Sand Fortress
Description You are going to the beach with the idea to build the greatest sand castle ever in your ...
- Educational Codeforces Round 44 (Rated for Div. 2)
题目链接:https://codeforces.com/contest/985 ’A.Chess Placing 题意:给了一维的一个棋盘,共有n(n必为偶数)个格子.棋盘上是黑白相间的.现在棋盘上有 ...
- Codeforces 985 最短水桶分配 沙堆构造 贪心单调对列
A B /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a, ...
- bzoj 3399: [Usaco2009 Mar]Sand Castle城堡
3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec Memory Limit: 128 MB Description 约翰用沙子建了一座城堡.正 ...
- BZOJ3399: [Usaco2009 Mar]Sand Castle城堡
3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 22 Solved: 17[Sub ...
- 3399: [Usaco2009 Mar]Sand Castle城堡
3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 37 Solved: 32[Sub ...
- 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 ...
随机推荐
- Velocity模板引擎笔记
模板引擎中判断对象是否为空: #if(!${jsonObj.data.buyerName} || ${jsonObj.data.buyerName} == '') <p>采 ...
- ios很好的开源库
Tim9Liu9/TimLiu-iOS 自己总结的iOS.mac开源项目及库,持续更新.. 目录 UI 下拉刷新 模糊效果 AutoLayout 富文本 图表 表相关与Tabbar 隐藏与显示 HUD ...
- nginx、mysql、php等各编译参数查询
查看nginx编译参数:/usr/local/nginx/sbin/nginx -V 查看apache编译参数:cat /usr/local/apache2/build/config.nice 查看m ...
- 织梦CMS首页、列表页文章如何调出该文章TAG标签?
1.如果是dedecms v5.7版本直接使用标签 [field:id function=GetTags(@me)/] 就可以调用出来了.只不过不带连接的. 2.如果需要连接请注释掉include/h ...
- silverlight 图片引入代码
private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e) { string str = t ...
- [推荐]Silverlight 2 开发者海报
从Brad Abrams的Blog上看到了一张Silverlight 2开发者海报,非常酷,拿出来与大家分享. [JPG版本 5.8MB] [PNG版本 6.5MB] [TIF版本 19.9 MB] ...
- Intel® Media SDK(一)
A cross-platform API for developing media applications on Windows* Fast video playback, encode, proc ...
- [Selenium] 如何使 InternetExplorerDriver 每次启动的端口不会随机变化
InternetExplorerDriver 在不指定任何参数的情况下,启动监听端口会随机变化.如果需要保证其端口固定不变,可通过InternetExplorerDriverService 达到目的. ...
- 「LuoguP1281」 书的复制(贪心
Description 大多数人的错误原因:尽可能让前面的人少抄写,如果前几个人可以不写则不写,对应的人输出0 0. 不过,已经修改数据,保证每个人都有活可干. // 现在要把m本有顺序的书分给k给人 ...
- servlet中的servletURL,servletURI和servletPath
String servletURL=request.getservletURL(); url:站点名+当前web应用名+(目录名)+页面名 String servletURI=reques ...