codeforces652AGabriel and Caterpillar(模拟题)

这题的题意是这样的:

这个人每天两点去观察毛毛虫,毛毛虫一开始在h1的位置,要去h2位置的苹果的地方,毛毛虫白天能上升a米/h,晚上要睡觉所以要下降b米/h,假设每天10点为白天,晚上10变成黑夜,问你毛毛虫要几天才能到达苹果的位置。

/* ***********************************************
Author        :yzkAccepted
Created Time  :2016/3/25 20:55:41
TASK		  :ggfly.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef __int64 ll;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int h1,h2,a,b;
	int day;
	int dit;
	scanf("%d%d",&h1,&h2);
	scanf("%d%d",&a,&b);
	dit=h2-h1;
	int h=a-b;
	day=0;
	if(8*a>=dit)
	{
		printf("0\n");
	}
	else
	{
		if(a<=b)
		{
			printf("-1\n");
		}
		else
		{
			dit-=8*a;
			dit+=12*b;
			while(dit>0)
			{
			//	printf("%d\n",dit);
				day++;
				dit-=12*a;
				if(dit<=0)
					break;
				else
				dit+=12*b;
			
			}
			printf("%d\n",day);
		}
	}
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值