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 ...
随机推荐
- centos 网络连接查看
安装iftop. 这个得先安装epel #yum install epel-replease -y #yum install iftop -y #iftop
- bzoj2436: [Noi2011]Noi嘉年华
我震惊了,我好菜,我是不是该退役(苦逼) 可以先看看代码里的注释 首先我们先考虑一下第一问好了真做起来也就这个能想想了 那么离散化时间是肯定的,看一手范围猜出是二维DP,那对于两个会场,一个放自变量, ...
- HDU3652 B-number —— 数位DP
题目链接:https://vjudge.net/problem/HDU-3652 B-number Time Limit: 2000/1000 MS (Java/Others) Memory L ...
- MYSQL进阶学习笔记五:MySQL函数的创建!(视频序号:进阶_13)
知识点六:MySQL函数的创建(13) 内置函数: 自定义函数: 首先查看是否已经开启了创建函数的功能: SHOW VARIABLES LIKE ‘%fun%’; 如果变量的值是OFF,那么需要开启 ...
- oracle实例的内存(SGA和PGA)调整,优化数据库性能
一.名词解释 (1)SGA:SystemGlobal Area是OracleInstance的基本组成部分,在实例启动时分配;系统全局域SGA主要由三部分构成:共享池.数据缓冲区.日志缓冲区. (2) ...
- 读取文件中的每行数据,并且存入到list中
有一个txt文件,每行都有数据,将每行的数据转换成list列表 例如: 5,6,7,8,1 9,1,3,4 如下实现: f = open('test1.txt','r') for i in f.rea ...
- 【转】Intellij idea 的maven项目如何通过maven自动下载jar包
原文地址: https://blog.csdn.net/machao0903/article/details/73368909 maven项目自动加载jar包 所需工具如下: Intellij IDE ...
- HBase之四--(1):Java操作Hbase进行建表、删表以及对数据进行增删改查,条件查询
1.搭建环境 新建JAVA项目,添加的包有: 有关Hadoop的hadoop-core-0.20.204.0.jar 有关Hbase的hbase-0.90.4.jar.hbase-0.90.4-tes ...
- ASP.NET Core:WebAppCoreReact
ylbtech-ASP.NET Core:WebAppCoreReact 1.返回顶部 1. 2. 3. 4. 5. 6. 7. 2. wwwroot 返回顶部 3. Clie ...
- cocos2d-x 坐标系解惑
1.CCTouch* touch->getLocation() ---- 返回当前触摸点在openGL坐标系中的位置 openGL坐标系,原点在左下角,x向右为正,y向上为正. 2.CCTouc ...