总时间限制: 

1000ms

内存限制: 

65536kB

描述

魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。

红司令部,City 1,City 2,……,City n,蓝司令部

两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值这两种属性。
有的武士可以拥有武器。武器有三种,sword, bomb,和arrow,编号分别为0,1,2。
双方的武士编号都是从1开始计算。红方制造出来的第 n 个武士,编号就是n。同样,蓝方制造出来的第 n 个武士,编号也是n。

不同的武士有不同的特点。
dragon 可以拥有一件武器。编号为n的dragon降生时即获得编号为 n%3 的武器。dragon还有“士气”这个属性,是个浮点数,其值为它降生后其司令部剩余生命元的数量除以造dragon所需的生命元数量。
ninja可以拥有两件武器。编号为n的ninja降生时即获得编号为 n%3 和 (n+1)%3的武器。
iceman有一件武器。编号为n的iceman降生时即获得编号为 n%3 的武器。
lion 有“忠诚度”这个属性,其值等于它降生后其司令部剩余生命元的数目。
wolf没特点。
请注意,在以后的题目里,武士的士气,生命值,忠诚度在其生存期间都可能发生变化,都有作用,武士手中的武器随着使用攻击力也会发生变化。

武士在刚降生的时候有一个生命值。

在每个整点,双方的司令部中各有一个武士降生。

红方司令部按照 iceman、lion、wolf、ninja、dragon 的顺序循环制造武士。

蓝方司令部按照 lion、dragon、ninja、iceman、wolf 的顺序循环制造武士。

制造武士需要生命元。

制造一个初始生命值为 m 的武士,司令部中的生命元就要减少 m 个。

如果司令部中的生命元不足以制造某个按顺序应该制造的武士,那么司令部就试图制造下一个。如果所有武士都不能制造了,则司令部停止制造武士。
给定一个时间,和双方司令部的初始生命元数目,要求你将从0点0分开始到双方司令部停止制造武士为止的所有事件按顺序输出。
一共有两种事件,其对应的输出样例如下:

1) 武士降生
输出样例: 004 blue lion 5 born with strength 5,2 lion in red headquarter
表示在 4点整,编号为5的蓝魔lion武士降生,它降生时生命值为5,降生后蓝魔司令部里共有2个lion武士。(为简单起见,不考虑单词的复数形式)注意,每制造出一个新的武士,都要输出此时司令部里共有多少个该种武士。
如果造出的是dragon,那么还要输出一行,例:
It has a arrow,and it's morale is 23.34
表示该dragon降生时得到了arrow,其士气是23.34(为简单起见,本题中arrow前面的冠词用a,不用an,士气精确到小数点后面2位,四舍五入)
如果造出的是ninja,那么还要输出一行,例:
It has a bomb and a arrow
表示该ninja降生时得到了bomb和arrow。
如果造出的是iceman,那么还要输出一行,例:
It has a sword
表示该iceman降生时得到了sword。
如果造出的是lion,那么还要输出一行,例:
It's loyalty is 24
表示该lion降生时的忠诚度是24。
2) 司令部停止制造武士
输出样例: 010 red headquarter stops making warriors
表示在 10点整,红方司令部停止制造武士

输出事件时:

首先按时间顺序输出;

同一时间发生的事件,先输出红司令部的,再输出蓝司令部的。

输入

第一行是一个整数,代表测试数据组数。

每组测试数据共两行。

第一行,一个整数M。其含义为: 每个司令部一开始都有M个生命元( 1 <= M <= 10000)

第二行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的初始生命值。它们都大于0小于等于10000

输出

对每组测试数据,要求输出从0时0分开始,到双方司令部都停止制造武士为止的所有事件。
对每组测试数据,首先输出“Case:n" n是测试数据的编号,从1开始
接下来按恰当的顺序和格式输出所有事件。每个事件都以事件发生的时间开头,时间以小时为单位,有三位。

样例输入


1
20
3 4 5 6 7


样例输出

Case:1
000 red iceman 1 born with strength 5,1 iceman in red headquarter
It has a bomb
000 blue lion 1 born with strength 6,1 lion in blue headquarter
It's loyalty is 14
001 red lion 2 born with strength 6,1 lion in red headquarter
It's loyalty is 9
001 blue dragon 2 born with strength 3,1 dragon in blue headquarter
It has a arrow,and it's morale is 3.67
002 red wolf 3 born with strength 7,1 wolf in red headquarter
002 blue ninja 3 born with strength 4,1 ninja in blue headquarter
It has a sword and a bomb
003 red headquarter stops making warriors
003 blue iceman 4 born with strength 5,1 iceman in blue headquarter
It has a bomb
004 blue headquarter stops making warriors

代码

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class clock {
public:
	static int hour;
};
int clock::hour = 0;
string list1[5] = { "iceman","lion","wolf","ninja","dragon" };
string list2[5] = { "lion","dragon","ninja","iceman","wolf" };
string weapon[3] = { "sword","bomb","arrow" };
class warrior {
public:
	
	warrior() {}
	virtual ~warrior() {}
	virtual string show_weapon() { return "no"; };   //纯虚函数会导致无法创建对象,反正不会
	virtual float show_morale() { return 0; };       //用到,所以随便返回些东西
	virtual int show_loyalty() { return 0; };
};
class wolf : public warrior {
public:
	static int strength;
	static bool canBorn(int _life) {
		return _life >= strength;
	}
	wolf() {}
	~wolf() {}
};
int wolf::strength = 0;
class dragon : public warrior {
	string weapon;
	float morale;
public:
	static int strength;
	static bool canBorn(int _life) {
		return _life >= strength;
	}
	dragon(string _w, float _m) : weapon(_w), morale(_m) {}
	~dragon() {}
	float show_morale() {
		return morale;
	}
	string show_weapon() {
		return weapon;
	}
};
int dragon::strength = 0;
class ninja : public warrior {
	string weapon1;
	string weapon2;
public:
	static int strength;
	static bool canBorn(int _life) {
		return _life >= strength;
	}
	ninja(string _w1, string _w2) :weapon1(_w1), weapon2(_w2) {}
	~ninja() {}
	string show_weapon() {
		return weapon1 + " and a " + weapon2;
	}
};
int ninja::strength = 0;
class iceman : public warrior {
	string weapon;
public:
	static int strength;
	static bool canBorn(int _life) {
		return _life >= strength;
	}
	iceman(string _w) : weapon(_w) {}
	~iceman() {}
	string show_weapon() {
		return weapon;
	}
};
int iceman::strength = 0;
class lion : public warrior {
	int loyalty;
public:
	static int strength;
	static bool canBorn(int _life) {
		return _life >= strength;
	}
	lion(int _l) : loyalty(_l) {}
	~lion() {}
	int show_loyalty() {
		return loyalty;
	}
};
int lion::strength = 0;
class Headquarter {
private:
	string flag;
	int num;
	int lifeUnit;
	string* list;
	int ptr;
	warrior* army[1000];
	int wolf_num, lion_num, ninja_num, iceman_num, dragon_num;
public:
	int least;        //表示制造武士需要的最少生命元,同时也是是否继续制造武士的标志
	Headquarter(string _f, int _l, int _le) : flag(_f), lifeUnit(_l), least(_le), num(0), ptr(0) {
		if (flag == "red")
			list = list1;
		else if (flag == "blue")
			list = list2;
		army[0] = new warrior;
		wolf_num = lion_num = ninja_num = iceman_num = dragon_num = 0;
	}
	~Headquarter() {}
	bool canBorn() {
		return lifeUnit >= least;
	}
	void produce() {
		if (!canBorn() && least) {
			cout << setw(3) << setfill('0') << clock::hour << ' ' << flag << ' ' << "headquarter stops making warriors" << endl;
			least = 0;    //此时已经无法继续制造武士,所以将它设为0
			return;
		}
		while (least)
		{
			if (ptr == 5)
				ptr = 0;
			if (list[ptr] == "iceman" && iceman::canBorn(lifeUnit)) {
				num++;
				iceman_num++;
				lifeUnit -= iceman::strength;
				army[num] = new iceman(weapon[num % 3]);
				cout << setw(3) << setfill('0') << clock::hour << ' ' << flag << " iceman " << num << " born with strength " << iceman::strength << "," << iceman_num << " iceman in " << flag << " headquarter" << endl;
				cout << "It has a " << army[num]->show_weapon() << endl;
				break;
			}
			else if (list[ptr] == "lion" && lion::canBorn(lifeUnit)) {
				num++;
				lion_num++;
				lifeUnit -= lion::strength;
				army[num] = new lion(lifeUnit);
				cout << setw(3) << setfill('0') << clock::hour << ' ' << flag << " lion " << num << " born with strength " << lion::strength << "," << lion_num << " lion in " << flag << " headquarter" << endl;
				cout << "It's loyalty is " << army[num]->show_loyalty() << endl;
				break;
			}
			else if (list[ptr] == "ninja" && ninja::canBorn(lifeUnit)) {
				num++;
				lifeUnit -= ninja::strength;
				ninja_num++;
				army[num] = new ninja(weapon[num % 3], weapon[(num + 1) % 3]);
				cout << setw(3) << setfill('0') << clock::hour << ' ' << flag << " ninja " << num << " born with strength " << ninja::strength << "," << ninja_num << " ninja in " << flag << " headquarter" << endl;
				cout << "It has a " << army[num]->show_weapon() << endl;
				break;
			}
			else if (list[ptr] == "wolf" && wolf::canBorn(lifeUnit)) {
				num++;
				lifeUnit -= wolf::strength;
				wolf_num++;
				army[num] = new wolf;
				cout << setw(3) << setfill('0') << clock::hour << ' ' << flag << " wolf " << num << " born with strength " << wolf::strength << "," << wolf_num << " wolf in " << flag << " headquarter" << endl;
				break;
			}
			else if (list[ptr] == "dragon" && dragon::canBorn(lifeUnit)) {
				num++;
				lifeUnit -= dragon::strength;
				dragon_num++;
				army[num] = new dragon(weapon[num % 3], 1.0 * lifeUnit / dragon::strength);
				cout << setw(3) << setfill('0') << clock::hour << ' ' << flag << " dragon " << num << " born with strength " << dragon::strength << "," << dragon_num << " dragon in " << flag << " headquarter" << endl;
				cout << "It has a " << army[num]->show_weapon() << ",and it's morale is " << fixed << setprecision(2) << army[num]->show_morale() << endl;
				break;
			}
			ptr++;
		}
		ptr++;
	}
};

int main() {
	int n, cs = 1;
	cin >> n;

	while (cs <= n)
	{
		int life, min;
		cin >> life;
		cin >> dragon::strength >> ninja::strength >> iceman::strength >> lion::strength >> wolf::strength;
		min = dragon::strength > ninja::strength ? ninja::strength : dragon::strength;
		min = min < iceman::strength ? min : iceman::strength;
		min = min < lion::strength ? min : lion::strength;
		min = min < wolf::strength ? min : wolf::strength;    //寻找最小所需生命元
		Headquarter red("red", life, min), blue("blue", life, min);
		cout << "Case:" << cs << endl;
		while(red.least || blue.least)
		{
			red.produce();
			blue.produce();
			clock::hour++;
		}
		clock::hour = 0;
		cs++;
	}

	return 0;
}

这一次应该写的比魔兽世界(一)好,大概……