首页 > 其他 > 详细

Codeforces Round #436 (Div. 2), problem: (C) Bus

时间:2017-10-02 20:12:57      阅读:289      评论:0      收藏:0      [点我收藏+]
#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

原文:http://www.cnblogs.com/LMissher/p/7622183.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!