⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2239.cpp

📁 哈尔滨工业大学ACM 竞赛网上在线试题集锦的源代码
💻 CPP
字号:
/*  This Code is Submitted by wywcgs for Problem 2239 on 2006-05-26 at 16:30:26 */ 
#include <cstdio>
#include <cstring>

const int V[][3] = { { 2, 1, 0 }, { 2, 0, 1 }, { 1, 0, 0 }, { 1, 2, 0 }, { 0, 2, 1 }, { 0, 1, 0 }, 
						{ 1, 0, 2 }, { 0, 1, 2 }, { 0, 0, 1 }, { 1, 1, 0 }, { 1, 0, 1 }, { 0, 1, 1 }, 
						{ 0, 0, 0 } };
const int L = 24;
const int POW[] = { 1, 100, 10000 };

int co;

class Country {
public:
	int g, s, b;
	void make(int);
	int score(int k) const { return g*POW[V[k][0]]+s*POW[V[k][1]]+b*POW[V[k][2]]; }
};
void Country::make(int o) {
	char name[L];
	scanf("%s %d %d %d", name, &g, &s, &b);
	if(!strcmp(name, "Canada")) co = o;
}

int main()
{
	Country c[L];
	int n, i, j;
	
	while(scanf("%d", &n) != EOF && n != 0) {
		co = -1;
		for(i = 0; i < n; i++) c[i].make(i);
		if(co == -1) { printf("Canada cannot win.\n"); continue; }
		bool win = false;
		for(i = 0; i < 13; i++) {
			win = true;
			for(j = 0; j < n && win; j++)
				if(c[j].score(i) > c[co].score(i)) win = false;
			if(win) break;
		}
		printf("Canada %s\n", win ? "wins!" : "cannot win.");
	}
	
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -