[CF]A. Gabriel and Caterpillar

題目:
http://codeforces.com/problemset/problem/652/A
---------------------------------------------------------------------------------

#include <bits/stdc++.h>
using namespace std;
const int n = 4e5 + 5;
int main()
{
  int h1, h2;
  int a, b;
  scanf("%d%d",&h1,&h2);
  scanf("%d%d",&a,&b);
  h1 += 8 * a;
  if(h1 >= h2){
    printf("0\n");
    return 0;
  }
  h1 -= 12 * b;
  if(a <= b){
    printf("-1\n");
    return 0;
  }
  int day = 1;
  for(int i=0;i<n;i++){
    h1 += 12 * a;
    if(h1 >= h2){
      printf("%d\n",day);
      return 0;
    }
    h1 -= 12 * b;
    day++;
  }
  printf("-1\n");
  return 0;
}

留言

這個網誌中的熱門文章

[ZJ]b513: 判斷質數-商競103

[ZJ]d212: 東東爬階梯