|
|
вернуться в форумWhere difference? #include <iostream> using namespace std; const int kmax=105; int K[kmax]; int L,n; int R(int x, int y) { if(x%y==0) return x/y; else return x/y+1; } int main() { cin>>L>>n; for(int i=1;i<=n;i++) cin>>K[i];
if(n==1) { if(L<K[1]) cout<<"YES"; else cout<<"NO"; return 0; }
int t1=R(L, K[1])*K[1], t2=K[1]; if(t1==t2) t1+=K[1];
for(int i=2;i<=n;i++) { t2+=K[i]; if(t1<t2) { cout<<"YES"; return 0; } t1=t2+R(t1-t2,K[i])*K[i]; if(t1==t2) t1+=K[i]; }
cout<<"NO"; return 0; } and #include <iostream> using namespace std; const int kmax=105; int K[kmax]; int L,n; int main() { cin>>L>>n; for(int i=1;i<=n;i++) cin>>K[i];
if(n==1) { if(L<K[1]) cout<<"YES"; else cout<<"NO"; return 0; }
int t1=(L/K[1]+1)*K[1], t2=K[1];
for(int i=2;i<=n;i++) { t2+=K[i]; if(t1<t2) { cout<<"YES"; return 0; } t1=t2+(1+(t1-t2)/K[i])*K[i]; }
cout<<"NO"; return 0; } ????????????????????????????????????????????? |
|
|