UCF Local Contest — September 5, 2015 Medal Ranking(模拟)

Medal Ranking filename: medal (Difficulty Level: Easy)
When different countries compete against each other (e.g., in the Olympics), they receive gold/silver/bronze medals. The countries can then be ranked in one of two ways: by “count” which is based on the total number of medals (regardless of the medal colors) or by “color” which is based on the number of gold medals (and silver medals if tied in gold medals, and bronze medals if tied in gold and silver).

The Problem:

Given the gold/silver/bronze medal counts for USA and Russia, you are to determine if USA wins in these two ranking methods.

The Input:

The first input line contains a positive integer, n, indicating the number of data sets to check. The sets are on the following n input lines, one set per line. Each set consists of 6 integers (each integer between 0 and 500 inclusive); the first three integers represent (respectively) the gold, silver, and bronze medal counts for USA; the last three integers provide this info for Russia (in same order).

The Output:
Print each input set. Then, on the next output line, print one of four messages (count, color, both, none), indicating how USA can win. USA will win by count if its total medal count is higher than the total for Russia. USA will win by color if it has more gold medals than Russia (if tied in gold, then USA must have more silver; if tied in gold and silver, then USA must have more bronze). Leave a blank line after the output for each test case.

Sample Input:
5
10 5 15 10 1 0
10 5 15 10 6 10
12 5 10 5 20 30
10 0 15 10 5 30
10 5 15 10 5 15
Sample Output:
10 5 15 10 1 0 both
10 5 15 10 6 10 count
12 5 10 5 20 30 color
10 0 15 10 5 30 none
10 5 15 10 5 15 none

题目链接:https://nanti.jisuanke.com/t/43387

solution:简单的模拟、和上一题类似

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, temp, arr[6];
	cin >> n;
	while (n--){
		bool count = false, color = false;
		for (int i = 0; i < 6; ++i){
			cin >> arr[i];
			if(i)putchar(' ');
			cout << arr[i];
		}
		putchar('\n');
		if (arr[0] + arr[1] + arr[2] > arr[3] + arr[4] + arr[5])count = true;
		if (arr[0] != arr[3]){
			if (arr[0] > arr[3])color = true;
		}else if (arr[1] != arr[4]){
			if (arr[1] > arr[4])color = true;
		}else if (arr[2] > arr[5])color = true;
		
		if (count && color)cout << "both" << endl << endl;
		else if (count)cout << "count" << endl << endl;
		else if (color)cout << "color" << endl << endl;
		else cout << "none" << endl << endl;
	}
	return 0;
 } 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值