CF1036A.Function Height

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a set of 2n+12n+1 integer points on a Cartesian plane. Points are numbered from 00 to 2n2n inclusive. Let PiP_i be the ii-th point. The xx-coordinate of the point PiP_i equals ii. The yy-coordinate of the point PiP_i equals zero (initially). Thus, initially Pi=(i,0)P_i=(i,0).

The given points are vertices of a plot of a piecewise function. The jj-th piece of the function is the segment PjPj+1P_{j}P_{j + 1}.

In one move you can increase the yy-coordinate of any point with odd xx-coordinate (i.e. such points are P1,P3,…,P2n−1P_1, P_3, \dots, P_{2n-1}) by 11. Note that the corresponding segments also change.

For example, the following plot shows a function for n=3n=3 (i.e. number of points is 2⋅3+1=72\cdot3+1=7) in which we increased the yy-coordinate of the point P1P_1 three times and yy-coordinate of the point P5P_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 yy-coordinate among all initial points in the plot (i.e. points P0,P1,…,P2nP_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+12n+1 vertices and having an area equal to kk. 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 101810^{18}.

给你一个笛卡尔平面上的 2n+12n+1 个整数点组成的集合。这些点编号从 00 到 2n2n(含端点)。记第 ii 个点为 PiP_i。点 PiP_i 的横坐标为 ii,纵坐标初始值为 00。因此,初始时有 Pi=(i,0)P_i = (i, 0)。

给定的这些点构成一个分段函数图像的顶点。该函数的第 jj 段即为线段 PjPj+1P_j P_{j+1}。

每次操作允许你将任意一个横坐标为奇数的点(即点 P1,P3,…,P2n−1P_1, P_3, \dots, P_{2n-1})的纵坐标增加 11。注意:相应连接的线段也会随之改变。

例如,下图展示了一个 n=3n = 3(即总点数为 2⋅3+1=72 \cdot 3 + 1 = 7)的情形:其中点 P1P_1 的纵坐标被增加了三次,点 P5P_5 的纵坐标被增加了一次:

定义该图像的面积为该图像下方、xx 轴(OX 轴)上方所围成的区域面积。例如,上图中图像的面积为 44(图中浅蓝色区域即为所求面积)。

定义该图像的高度为所有初始点(即 P0,P1,…,P2nP_0, P_1, \dots, P_{2n})中纵坐标的最大值。上图中图像的高度为 33。

你的任务是:对于由 2n+12n+1 个顶点构成、且面积恰好为 kk 的图像,求其可能的最小高度。注意:无需最小化操作次数。

容易看出,通过上述操作所能得到的任何答案均存在,且必为不超过 101810^{18} 的整数。

输入格式

The first line of the input contains two integers nn and kk (1≤n,k≤10181 \le n, k \le 10^{18}) — the number of vertices in a plot of a piecewise function and the area we need to obtain.

输入的第一行包含两个整数 nn 和 kk(1≤n,k≤10181 \le n, k \le 10^{18})——分别为分段函数图像的顶点数以及我们需要得到的面积。

输出格式

Print one integer — the minimum possible height of a plot consisting of 2n+12n+1 vertices and with an area equals kk. 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 101810^{18}.

输出一个整数——由 2n+12n+1 个顶点组成且面积恰好为 kk 的折线图的最小可能高度。容易看出,通过执行上述操作总能得到某个答案,且该答案一定是一个不超过 101810^{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.

第一个样例的一种可能答案:

该图形的面积为 3,高度为 1。

第二个样例仅有一种可能答案:

该图形的面积为 12,高度为 3。

输入解题思路,AI测评打分。不知道怎么写?

首页