列表

详情


NC220437. Jam-packed

描述

The fruit harvest has been good this year, which means that your jam-selling company, which produces the price-winning Berry Artisanal and Pure Compote, is shipping out jam left and right! A customer has recently placed a huge order of n jars of jam. To ship these jars, you put them into boxes, each of which can hold up to k jars.

As is always the case with fragile goods, the jars might break in the process of being delivered. You want to avoid the jars bouncing around in their boxes too much, as that signifificantly increases the chance that they break. To circumvent this, you want to avoid having boxes that are too empty: that would inevitably result in the uncontrolled bouncing around, and subsequently breaking, of the jars. In particular, you want the box with the least number of jars to be as full as possible. In order to estimate the risk you are taking with your precious jars, you would like to know: how many jars does this box contain?

输入描述

The input consists of:
    • A line with two integers n (1 ≤ n ≤ 1018), the number of jars that need to be packed, and k (1 ≤ k ≤ 1018), the number of jars a single box can hold.

输出描述

Output the number of jars that the least fifilled box contains.

示例1

输入:

10 3

输出:

2

示例2

输入:

16 4

输出:

4

示例3

输入:

1 2

输出:

1

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++(clang++ 11.0.1) 解法, 执行用时: 2ms, 内存消耗: 460K, 提交时间: 2023-07-14 19:28:40

#include<iostream>
long long n,m;
signed main(){std::cin>>n>>m&&n%m?std::cout<<n/(n/m+1):std::cout<<m;}

Python3(3.9) 解法, 执行用时: 49ms, 内存消耗: 6856K, 提交时间: 2021-04-11 22:24:43

n,k=map(int,input().split())
print(n//((n+k-1)//k))

上一题