CodeFores Round53(div.2) D.Berland Fair
Posted huluxin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeFores Round53(div.2) D.Berland Fair相关的知识,希望对你有一定的参考价值。
1 #include <iomanip> 2 #include <iostream> 3 #include <cstdio> 4 #include <cmath> 5 #include <cstring> 6 #include <algorithm> 7 #include <queue> 8 #include <stack> 9 #include <vector> 10 #include <map> 11 using namespace std; 12 const int nmax=200200; 13 int main(int argc, char *argv[]) 14 { 15 int n,a[nmax]; 16 long long t; 17 scanf("%d%I64d",&n,&t); 18 int mi=1e9+10; 19 for(int i=1;i<=n;i++) 20 { 21 scanf("%d",&a[i]); 22 if(a[i]>t) 23 { 24 i--; 25 n--; 26 } 27 if(a[i]<mi) 28 mi=a[i]; 29 } 30 long long sum=0; 31 long long l=1; 32 while(1) 33 { 34 if(l==1) 35 { 36 long long sum1=0,x=0; 37 for(int i=1;i<=n;i++) 38 { 39 if(t>=a[i]) 40 sum1+=a[i],x++; 41 } 42 if(sum1==0) 43 break; 44 sum+=(t/sum1*x); 45 t-=(t/sum1*sum1); 46 } 47 if(t<mi) 48 break; 49 if(a[l]<=t) 50 t-=a[l],sum++; 51 l++; 52 if(l==n+1) 53 l=1; 54 } 55 printf("%I64d ",sum); 56 return 0; 57 } 58
1 #include <iomanip> 2 #include <iostream> 3 #include <cstdio> 4 #include <cmath> 5 #include <cstring> 6 #include <algorithm> 7 #include <queue> 8 #include <stack> 9 #include <vector> 10 #include <map> 11 using namespace std; 12 const int nmax=200200; 13 int main(int argc, char *argv[]) 14 { 15 int n,a[nmax]; 16 long long t; 17 scanf("%d%I64d",&n,&t); 18 for(int i=1;i<=n;i++) 19 scanf("%d",&a[i]); 20 long long s,sum=0; 21 int x=0; 22 while(1) 23 { 24 for(int i=1;i<=n;i++) 25 if(s+a[i]<=t) 26 s+=a[i],x++; 27 if(s==0) 28 break; 29 sum+=t/s*x,t%=s; 30 s=0,x=0; 31 } 32 printf("%I64d ",sum); 33 return 0; 34 } 35
以上是关于CodeFores Round53(div.2) D.Berland Fair的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 53 (Rated for Div. 2)
Educational Codeforces Round 53 (Rated for Div. 2)
Educational Codeforces Round 53 (Rated for Div. 2) C. Vasya and Robot 二分 + 尺取
Educational Codeforces Round 53 (Rated for Div. 2) E. Segment Sum
Educational Codeforces Round 53 (Rated for Div. 2)G. Yet Another LCP Problem
Educational Codeforces Round 53 (Rated for Div. 2) E. Segment Sum