A12003 | Function Height
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given a set of $2n+1$ integer points on a Cartesian plane. Points are numbered from $0$ to $2n$ inclusive. Let $P_i$ be the $i$ -th point. The $x$ -coordinate of the point $P_i$ equals $i$ . The $y$ -coordinate of the point $P_i$ equals zero (initially). Thus, initially $P_i=(i,0)$ .
The given points are vertices of a plot of a piecewise function. The $j$ -th piece of the function is the segment $P_{j}P_{j + 1}$ .
In one move you can increase the $y$ -coordinate of any point with odd $x$ -coordinate (i.e. such points are $P_1, P_3, \dots, P_{2n-1}$ ) by $1$ . Note that the corresponding segments also change.
For example, the following plot shows a function for $n=3$ (i.e. number of points is $2\cdot3+1=7$ ) in which we increased the $y$ -coordinate of the point $P_1$ three times and $y$ -coordinate of the point $P_5$ one time:
Let the area of the plot be the area below this plot and above the coordinate axis OX. For example, the area of the plot on the picture above is 4 (the light blue area on the picture above is the area of the plot drawn on it).
Let the height of the plot be the maximum $y$ -coordinate among all initial points in the plot (i.e. points $P_0, P_1, \dots, P_{2n}$ ). The height of the plot on the picture above is 3.
Your problem is to say which minimum possible height can have the plot consisting of $2n+1$ vertices and having an area equal to $k$ . Note that it is unnecessary to minimize the number of moves.
It is easy to see that any answer which can be obtained by performing moves described above always exists and is an integer number not exceeding $10^{18}$ .
The given points are vertices of a plot of a piecewise function. The $j$ -th piece of the function is the segment $P_{j}P_{j + 1}$ .
In one move you can increase the $y$ -coordinate of any point with odd $x$ -coordinate (i.e. such points are $P_1, P_3, \dots, P_{2n-1}$ ) by $1$ . Note that the corresponding segments also change.
For example, the following plot shows a function for $n=3$ (i.e. number of points is $2\cdot3+1=7$ ) in which we increased the $y$ -coordinate of the point $P_1$ three times and $y$ -coordinate of the point $P_5$ one time:
Let the area of the plot be the area below this plot and above the coordinate axis OX. For example, the area of the plot on the picture above is 4 (the light blue area on the picture above is the area of the plot drawn on it).Let the height of the plot be the maximum $y$ -coordinate among all initial points in the plot (i.e. points $P_0, P_1, \dots, P_{2n}$ ). The height of the plot on the picture above is 3.
Your problem is to say which minimum possible height can have the plot consisting of $2n+1$ vertices and having an area equal to $k$ . Note that it is unnecessary to minimize the number of moves.
It is easy to see that any answer which can be obtained by performing moves described above always exists and is an integer number not exceeding $10^{18}$ .
输入格式
The first line of the input contains two integers $n$ and $k$ ( $1 \le n, k \le 10^{18}$ ) — the number of vertices in a plot of a piecewise function and the area we need to obtain.
输出格式
Print one integer — the minimum possible height of a plot consisting of $2n+1$ vertices and with an area equals $k$ . It is easy to see that any answer which can be obtained by performing moves described above always exists and is an integer number not exceeding $10^{18}$ .
输入输出样例
输入 #1
4 3
输出 #1
1
输入 #2
4 12
输出 #2
3
输入 #3
999999999999999999 999999999999999986
输出 #3
1
One of the possible answers to the first example:
The area of this plot is 3, the height of this plot is 1.
There is only one possible answer to the second example:
The area of this plot is 12, the height of this plot is 3.
The area of this plot is 3, the height of this plot is 1.There is only one possible answer to the second example:
The area of this plot is 12, the height of this plot is 3.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?