【 Educational Codeforces Round 53 (Rated for Div. 2) D. Berland Fair】思维题
程序员文章站
2024-03-06 21:03:44
...
D. Berland Fair
题意
做法
代码
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
ll a[maxn];
int main()
{
int n;
ll T;
scanf("%d%lld",&n,&T);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
ll ans=0;
while(T)
{
ll sum=0;
ll cnt=0;
for(int i=1;i<=n;i++)
{
if(a[i]<=T)
{
cnt++;
sum+=a[i];
}
}
if(cnt==0) break;
if(T<sum)
{
for(int i=1;i<=n;i++)
{
if(T>=a[i])
{
ans++;
T-=a[i];
}
}
}
else
{
ans+=1LL*cnt*(T/sum);
T=T%sum;
}
}
printf("%lld\n",ans);
return 0;
}
上一篇: ASP.NET 文件断点续传实现代码
推荐阅读
-
Educational Codeforces Round 53 (Rated for Div. 2)D. Berland Fair
-
【 Educational Codeforces Round 53 (Rated for Div. 2) D. Berland Fair】思维题
-
Educational Codeforces Round 81 (Rated for Div. 2) - D. Same GCDs - 扩欧+欧拉函数
-
Educational Codeforces Round 65 (Rated for Div. 2) E. Range Deleting(双指针+思维)
-
Educational Codeforces Round 97 (Rated for Div. 2) D. Minimal Height Tree
-
Educational Codeforces Round 60 (Rated for Div. 2) ----A - Best Subsegment(思维题)
-
D. Sequence and Swaps(模拟+枚举) Educational Codeforces Round 99 (Rated for Div. 2)
-
Educational Codeforces Round 91 (Rated for Div. 2) D. Berserk And Fireball
-
Educational Codeforces Round 83 (Rated for Div. 2) D. Count the Arrays
-
Codeforces Educational Codeforces Round 80 (Rated for Div. 2) E - Messenger Simulator(树状数组+思维)