P9299 [CCC 2023 J1] Deliv-e-droid

题目描述

In the game, Deliv-e-droid, a robot droid has to deliver packages while avoiding obstacles.

At the end of the game, the final score is calculated based on the following point system:

  • Gain 5050 points for every package delivered.
  • Lose 1010 points for every collision with an obstacle.
  • Earn a bonus 500500 points if the number of packages delivered is greater than the number of collisions with obstacles.

Your job is to determine the final score at the end of a game.

输入格式

The input will consist of two lines. The first line will contain a non-negative integer PP,representing the number of packages delivered. The second line will contain a non-negative integer CC,representing the number of collisions with obstacles.

输出格式

The output will consist of a single integer FF,representing the final score.

题意翻译

机器人 Deliv-e-droid 在送快递,如果它成功地将一个快递送达,则它获得 50 元钱,如果未能成功送达,它被扣除 10 元钱。特别地,如果它送达的快递的数量大于未送达的,它会得到 500 元钱的奖励。

现在已知 Deliv-e-droid 送达了 P 个快递,未送达 C 个(0≤P,C≤100),请实现一个程序,求出 Deliv-e-droid 所获得的钱(如果是倒扣的话用负数表示)。

输入输出样例

输入 #1

5
2

输出 #1

730

输入 #2

0
10

输出 #2

-100

这道题属于一道if结构的练习,只需要判断n>m时ans+=500就ok

#include
using namespace std;
int n,m,ans;
int main(){
	scanf("%d%d",&n,&m);
	ans=n*50-m*10;
	if(n>m)ans+=500;
	printf("%d",ans);
	return 0;
    }

你可能感兴趣的:(c++,洛谷,编程,c++)