CF1073D.Berland Fair

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

XXI Berland Annual Fair is coming really soon! Traditionally fair consists of nn booths, arranged in a circle. The booths are numbered 11 through nn clockwise with nn being adjacent to 11 . The ii -th booths sells some candies for the price of aia_i burles per item. Each booth has an unlimited supply of candies.

Polycarp has decided to spend at most TT burles at the fair. However, he has some plan in mind for his path across the booths:

  • at first, he visits booth number 11 ;
  • 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 nn and TT ( 1n21051 \le n \le 2 \cdot 10^5 , 1T10181 \le T \le 10^{18} ) — the number of booths at the fair and the initial amount of burles Polycarp has.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai1091 \le a_i \le 10^9 ) — the price of the single candy at booth number ii .

输出格式

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:

  1. Booth 11 , buys candy for 55 , T=33T = 33 ;
  2. Booth 22 , buys candy for 22 , T=31T = 31 ;
  3. Booth 33 , buys candy for 55 , T=26T = 26 ;
  4. Booth 11 , buys candy for 55 , T=21T = 21 ;
  5. Booth 22 , buys candy for 22 , T=19T = 19 ;
  6. Booth 33 , buys candy for 55 , T=14T = 14 ;
  7. Booth 11 , buys candy for 55 , T=9T = 9 ;
  8. Booth 22 , buys candy for 22 , T=7T = 7 ;
  9. Booth 33 , buys candy for 55 , T=2T = 2 ;
  10. Booth 11 , buys no candy, not enough money;
  11. Booth 22 , buys candy for 22 , T=0T = 0 .

No candy can be bought later. The total number of candies bought is 1010 .

In the second example he has 11 burle left at the end of his path, no candy can be bought with this amount.

首页