A. Function Height

滴答滴答---题目链接

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given a set of 2n+12n+1 integer points on a Cartesian plane. Points are numbered from 00 to 2n2n inclusive. Let PiPi be the ii-th point. The xx-coordinate of the point PiPi equals ii. The yy-coordinate of the point PiPi equals zero (initially). Thus, initially Pi=(i,0)Pi=(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+1PjPj+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−1P1,P3,…,P2n−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⋅3+1=7) in which we increased the yy-coordinate of the point P1P1 three times and yy-coordinate of the point P5P5 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,…,P2nP0,P1,…,P2n). 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 10181018.

Input

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

Output

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 10181018.

Examples

input

Copy

4 3

output

Copy

1

input

Copy

4 12

output

Copy

3

input

Copy

999999999999999999 999999999999999986

output

Copy

1

Note

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.

题意 给定笛卡尔坐标系(平面直角坐标系)x轴正方向上的一条线段OP_{2n}OP  2n ​     (O为原点),长度为nn,每次操作定义为将这条线段上任意一个下标为奇数的点向上平移一个单位。经过若干次操作后会形成许多三角形。现给定正整数k,要求通过若干次操作使得三角形的面积之和为kk,求其中高最大的三角形其高的最小值是多少、  解题思路 既然要让高度最大的高尽量小,那么我们就要考虑“平均主义”,即:让每个三角形分摊总面积。设有nn个三角形,其高分别为h_1,h_2,...,h_nh  1 ​     ,h  2 ​     ,...,h  n ​     ,由于每次操作是平移下标为奇数的点,而奇数点必然在两个下标为偶数的点之间,因此这些三角形的底都为2。由三角形面积=底*高÷2,得2*(h_1+h_2+...+h_n)/2=k2∗(h  1 ​     +h  2 ​     +...+h  n ​     )/2=k,那么最大高的最小值就是n/kn/k.  签到题,难度较为基础,花了大概七八分钟推出来了式子。

 代码分享

注意n%k!=0的情况要特判。

#include <iostream>
#include<stdlib.h>
using namespace std;

int main()
{
    long long int n,i,m;
    long long int ans;
    cin>>n>>m;
    if(m<=n)ans=1;
    else if(m%n==0) ans=m/n;
    else ans=m/n+1;
    cout<<ans<<endl;
    return 0;
}

 

抱歉,我之前给出的代码中有错误。在Google Earth Engine中,`world.bounds()`返回的是一个矩形区域的几何对象,而不是一个几何对象的方法。因此,我们无法直接使用`.height()`方法来获取矩形区域的高度。相反,我们可以使用`ee.Geometry.distance()`函数来计算矩形区域在纬度方向上的高度。以下是修正后的代码示例: ```javascript // 定义全球范围的矩形区域 var world = ee.Geometry.Rectangle(-180, -90, 180, 90); // 定义网格分辨率(4km) var gridResolution = 4000; // 计算纬度和经度的网格数量 var latGridCount = ee.Number(world.distance('min-y', 'max-y')).divide(gridResolution).toInt(); var lonGridCount = ee.Number(world.distance('min-x', 'max-x')).divide(gridResolution).toInt(); // 生成纬度和经度的网格 var latGrid = ee.List.sequence(-90, 90, gridResolution).map(function(lat) { return ee.Geometry.LineString([[-180, lat], [180, lat]]); }); var lonGrid = ee.List.sequence(-180, 180, gridResolution).map(function(lon) { return ee.Geometry.LineString([[lon, -90], [lon, 90]]); }); // 合并纬度和经度的网格 var grid = ee.FeatureCollection(ee.List([latGrid, lonGrid]).flatten()); // 可视化网格 Map.addLayer(grid, {}, 'Grid'); // 打印生成的网格信息 print('Grid:', grid); ``` 在上述代码中,我们使用`ee.Geometry.distance()`函数来计算矩形区域在纬度和经度方向上的距离,从而得到纬度和经度的网格数量。然后,我们使用`ee.List.sequence()`函数生成纬度和经度的网格线。最后,我们将纬度和经度的网格合并为一个特征集合,并将其添加到地图上进行可视化,并使用`print`函数打印网格的信息。 请注意,这只是一种方法来生成全球4km网格,并且可能不是最精确的方法。您可以根据需要进行修改和调整。在Google Earth Engine中,还有其他方法来生成网格,您可以根据具体要求进行进一步研究和探索。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值