codeforces652AGabriel and Caterpillar(模拟题)

来源:互联网 发布:nba2kol奥尼尔隐藏数据 编辑:程序博客网 时间:2024/05/22 06:11

这题的题意是这样的:

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

/* ***********************************************Author        :yzkAcceptedCreated Time  :2016/3/25 20:55:41TASK  :ggfly.cppLANG          :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;elsedit+=12*b;}printf("%d\n",day);}}    return 0;}



0 0
原创粉丝点击