XXI Berland Annual Fair is coming really soon! Traditionally fair consists of nnbooths, arranged in a circle. The booths are numbered 11 through nn clockwise with nnbeing adjacent to 11. The ii-th booths sells some candies for the price of aiai 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.

Input

The first line contains two integers nn and TT (1≤n≤2⋅1051≤n≤2⋅105, 1≤T≤10181≤T≤1018) — the number of booths at the fair and the initial amount of burles Polycarp has.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109) — the price of the single candy at booth number ii.

Output

Print a single integer — the total number of candies Polycarp will buy.

Examples

Input
3 38
5 2 5
Output
10
Input
5 21
2 4 100 2 6
Output
6

Note

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.

题目大意:

n种糖果围成一圈,每种糖果每个ai元。初始时你有t元,接着你从1开始疯狂地绕圈。一旦你发现有糖果能买,你就买一个。直到一个糖果都买不起。问最后你买了多少个糖果。

稍微带点技巧的模拟。

若一个周期的和小于剩余的t,就直接买几个周期,不必一个个模拟。

然后遇到买不起的则将他从周期中删除。

注意用long long

#include<cstdio>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#define lol long long
#define maxn 200000 using namespace std; lol a[maxn+]; int main()
{
lol n,t;
scanf("%lld%lld",&n,&t);
lol sum=;
for(int i=;i<=n;i++)
{
scanf("%lld",a+i);
sum+=a[i];
} lol ans=;
lol cur=n;
lol num=n;
while()
{
ans+=(t/sum)*num;
t=t%sum;
//printf("%lld\n",t);
for(int i=;;i++)
{
//printf("%lld %lld\n",a[(cur+i-1)%n+1],t);
if(a[(cur+i-)%n+]==-)
continue;
if(a[(cur+i-)%n+]>t)
{
sum-=a[(cur+i-)%n+];
num--;
a[(cur+i-)%n+]=-;
cur=(cur+i-)%n+;
break;
}
t-=a[(cur+i-)%n+];
ans++;
} if(num==)
break;
}
printf("%lld\n",ans); return ;
}

好久没有更新博客了。

曾经被炒上天的ACM,如今却有些人走茶凉的味道。

正确的事是要坚持的。

最新文章

  1. HDU 2243 考研路茫茫——单词情结(AC自动机+DP+快速幂)
  2. sqlite3 根据实体自动生成建表语句
  3. 最短路径问题的Dijkstra和SPFA算法总结
  4. js返回顶部
  5. laravel 中 与前端的一些事2 之使用Gulp编译sass
  6. FFRPC应用之Client/Server
  7. LoadRunner 11 完整卸载
  8. mongodb的连接和开启安全验证
  9. 委托、事件和Lambda
  10. CF_402F dp+组合数学
  11. ADS的默认连接分析及编译器产生符号解惑
  12. Windows Server基础架构云参考架构:硬件之上的设计
  13. Spring—请求映射之URL路径映射
  14. Spyder调试错误-&quot;TypeError: decoding Unicode is not supported&quot;
  15. can&#39;t find which disk is full
  16. ETHREAD APC
  17. beta冲刺5
  18. 构建Maven父子工程
  19. robotframework之滚动条
  20. MVC基于角色权限控制--管理角色

热门文章

  1. windows 10上源码编译libjpeg-turbo和使用教程 | compile and use libjpeg-turbo on windows 10
  2. 简单地认识一下 HTML
  3. Docker harbor 安装和基础操作
  4. C语言博客作业11
  5. JQuery动态添加控件并取值
  6. Netty学习——基于netty实现简单的客户端聊天小程序
  7. 优雅解决 SpringBoot 工程中多环境下 application.properties 的维护问题
  8. 小白学 Python 爬虫(14):urllib 基础使用(四)
  9. 利用python实现dll依赖关系导出
  10. IOS UISwitch 控件