CF1073D.Berland Fair
普及/提高-
通过率:0%
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.
输入格式
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 .
输出格式
Print a single integer — the total number of candies Polycarp will buy.
输入输出样例
输入#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.