CF1073D.Berland Fair
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
XXI Berland Annual Fair is coming really soon! Traditionally fair consists of n booths, arranged in a circle. The booths are numbered 1 through n clockwise with n being adjacent to 1. The i-th booths sells some candies for the price of ai burles per item. Each booth has an unlimited supply of candies.
Polycarp has decided to spend at most T burles at the fair. However, he has some plan in mind for his path across the booths:
- at first, he visits booth number 1;
- if he has enough burles to buy exactly one candy from the current booth, then he buys it immediately;
- then he proceeds to the next booth in the clockwise order (regardless of if he bought a candy or not).
Polycarp's money is finite, thus the process will end once he can no longer buy candy at any booth.
Calculate the number of candies Polycarp will buy.
第二十一届贝尔兰年度集市即将盛大开幕!按照传统,集市由 n 个摊位组成,这些摊位围成一个圆圈。摊位按顺时针方向编号为 1 至 n,其中摊位 n 与摊位 1 相邻。第 i 个摊位以每颗 ai 卢布的价格出售糖果,且每个摊位的糖果供应量无限。
波利卡普决定在集市上最多花费 T 卢布。然而,他已为自己在各摊位间的行进路径制定了如下计划:
- 首先,他访问编号为 1 的摊位;
- 若他当前拥有的卢布数足以恰好购买该摊位的一颗糖果,则他立即购买一颗;
- 然后,无论是否购买了糖果,他都前往顺时针方向的下一个摊位。
由于波利卡普的资金有限,该过程将在他无法于任意摊位购买糖果时终止。
请计算波利卡普最终将购买的糖果总数。
输入格式
The first line contains two integers n and T (1≤n≤2⋅105, 1≤T≤1018) — the number of booths at the fair and the initial amount of burles Polycarp has.
The second line contains n integers a1,a2,…,an (1≤ai≤109) — the price of the single candy at booth number i.
第一行包含两个整数 n 和 T(1≤n≤2⋅105,1≤T≤1018)—— 分别表示集市上摊位的数量以及 Polycarp 初始拥有的 burles 数量。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)—— 表示第 i 个摊位处单颗糖果的价格。
输出格式
Print a single integer — the total number of candies Polycarp will buy.
输出一个整数——Polycarp 将购买的糖果总数。
输入输出样例
输入#1
3 38 5 2 5
输出#1
10
输入#2
5 21 2 4 100 2 6
输出#2
6
说明/提示
Let's consider the first example. Here are Polycarp's moves until he runs out of money:
- Booth 1, buys candy for 5, T=33;
- Booth 2, buys candy for 2, T=31;
- Booth 3, buys candy for 5, T=26;
- Booth 1, buys candy for 5, T=21;
- Booth 2, buys candy for 2, T=19;
- Booth 3, buys candy for 5, T=14;
- Booth 1, buys candy for 5, T=9;
- Booth 2, buys candy for 2, T=7;
- Booth 3, buys candy for 5, T=2;
- Booth 1, buys no candy, not enough money;
- Booth 2, buys candy for 2, T=0.
No candy can be bought later. The total number of candies bought is 10.
In the second example he has 1 burle left at the end of his path, no candy can be bought with this amount.
我们来考虑第一个例子。以下是波利卡普在花光所有钱之前的所有行动:
- 摊位 1,购买糖果花费 5,T=33;
- 摊位 2,购买糖果花费 2,T=31;
- 摊位 3,购买糖果花费 5,T=26;
- 摊位 1,购买糖果花费 5,T=21;
- 摊位 2,购买糖果花费 2,T=19;
- 摊位 3,购买糖果花费 5,T=14;
- 摊位 1,购买糖果花费 5,T=9;
- 摊位 2,购买糖果花费 2,T=7;
- 摊位 3,购买糖果花费 5,T=2;
- 摊位 1,无法购买糖果(钱不够);
- 摊位 2,购买糖果花费 2,T=0。
此后无法再购买任何糖果。总共购买的糖果数量为 10。
在第二个例子中,他在走完全程后还剩余 1 卢布,但该金额不足以购买任何糖果。
输入解题思路,AI测评打分。不知道怎么写?