codeforces Round #523
A. Coins
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
You have unlimited number of coins with values 1,2,…,n1,2,…,n. You want to select some set of coins having the total value of SS.
It is allowed to have multiple coins with the same value in the set. What is the minimum number of coins required to get sum SS?
Input
The only line of the input contains two integers nn and SS (1≤n≤1000001≤n≤100000, 1≤S≤1091≤S≤109)
Output
Print exactly one integer — the minimum number of coins required to obtain sum SS.
Examples
input
Copy
5 11
output
Copy
3
input
Copy
6 16
output
Copy
3
Note
In the first example, some of the possible ways to get sum 1111 with 33 coins are:
- (3,4,4)(3,4,4)
- (2,4,5)(2,4,5)
- (1,5,5)(1,5,5)
- (3,3,5)(3,3,5)
It is impossible to get sum 1111 with less than 33 coins.
In the second example, some of the possible ways to get sum 1616 with 33 coins are:
- (5,5,6)(5,5,6)
- (4,6,6)(4,6,6)
It is impossible to get sum 1616 with less than 33 coins.
(签到题也要写)
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, s;
scanf("%d%d", &n, &s);
printf("%d\n", s / n + ((s % n) != 0));
return 0;
}
本文介绍了一道来自Codeforces竞赛的问题,即如何使用无限数量的面值从1到n的硬币组成总金额S,目标是找到达到此总金额所需的最少硬币数量。文章提供了输入输出样例及解释,并附带了简洁的C++代码实现。
783

被折叠的 条评论
为什么被折叠?



