CodeForces 652A Gabriel and Caterpillar

简单模拟。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int h1,h2;
int a,b;

int main()
{
    scanf("%d%d",&h1,&h2);
    scanf("%d%d",&a,&b);
    if(h1+8*a>=h2) printf("0\n");
    else if(h1+8*a<h2&&b>=a) printf("-1\n");
    else
    {
        h1=h1+8*a;
        int ans=0;
        while(1)
        {
            ans++;
            h1=h1-12*b;
            h1=h1+12*a;
            if(h1>=h2) break;
        }
        printf("%d\n",ans);
    }
    return 0;
}

 

posted @ 2016-03-26 10:54  Fighting_Heart  阅读(240)  评论(0编辑  收藏  举报