This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
//FILE *input=freopen("input.txt","r",stdin);
long long int swap(long long int &a,long long int &b){
long long int c;
c=a;
a=b;
b=c;
}
int main(){
long long int lh,s,e,l,b;
long long int cnt=0,cnt2;
long long int k;
scanf("%lld%lld%lld%lld%lld",&lh,&s,&e,&l,&b);
if(l<b){
swap(l,b);
swap(s,e);
}
//l>=b
k=lh*2-l;
if(s>lh*2)
{
cnt=(s-lh*2)/k;
s-=cnt*k;
e+=cnt*b;
if(s>lh*2){
s-=k;
cnt++;
e+=b;
}
}
else{
cnt=0;
}
if(s==0){
}
else if(s<=lh){
s=0;
e-=lh;
if(e>0)
e+=b;
cnt++;
}
else{
s=0;
cnt++;
e+=b;
}
k=lh*2-b;
if(e>lh*2){
cnt2=(e-lh*2)/k;
cnt+=cnt2;
e-=cnt2*k;
if(e>lh*2){
e-=k;
cnt++;
}
}
else{
}
if(e<=0){
}
else{
cnt++;
}
printf("%lld",cnt);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |