3935 - 喵同学的小鱼干

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

喵同学特别喜欢吃小鱼干,一看到小鱼干就会吃个不停。由于她想吃到更多的小鱼干,于是她决定去碰碰手气。已知喵同学赢一局可以赢得a只小鱼干,输一局会输掉b只小鱼干,喵同学现在有100只小鱼干作为本金,则她赢了x局输了y局后还有多少只小鱼干?

题目输入

给出四个整数a, b, x, y以空格隔开;

1<= a, b <=101<= x, y <=100

题目输出

输出喵同学最后可以吃到的小鱼干数

输入/输出样例

输入格式

1 1 1 1

输出格式

100

C++解答

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

int main()
{
  //freopen("in.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  int a, b, x, y;
  while(scanf("%d%d%d%d", &a, &b, &x, &y) != EOF)
  {
    int ans = 100 + a * x - b * y;
    if(ans <= 0)
      printf("0\n");
    else
      printf("%d\n", ans);
  }
  return 0;
}