Codeforces Round #436 (Div. 2), problem: (C) Bus
阿新 • • 發佈:2017-10-02
cst lag () turn code span cpp urn print
#include <cstdio>
int main(){
long long a,b,f,k,i,tot,s[11000],cnt;
scanf("%lld%lld%lld%lld",&a,&b,&f,&k);
tot=0,s[tot]=0,cnt=0;
while(cnt<k*a){
tot++;
if(tot%2==0){
cnt+=a;
s[tot]=cnt-f;
}
else{
cnt+=a;
s[tot]=cnt-a+f;
}
}
tot++;
s[tot]=k*a;
cnt=0;
int ans=0,flag=1;
for(int i=1;i<=tot;i++){
//printf("%d\n",s[i]);
if(s[i]-s[cnt]<=b){
continue;
}
else{
if(i-cnt==1){
flag=0;
break;
}
else{
cnt=i-1;
i=i-1;
ans++;
}
}
//printf("%d\n",ans);
}
flag==1?printf("%d\n",ans):printf("-1\n");
return 0;
}
Codeforces Round #436 (Div. 2), problem: (C) Bus