One of the World of Warcraft: preparations, World of Warcraft preparations

Source: Internet
Author: User

One of the World of Warcraft: preparations, World of Warcraft preparations
Source: POJ

Note: Total time limit: 1000 ms memory limit: 65536kB

Description

The west of World of Warcraft is the headquarters of the red magic army, and the East is the headquarters of the Blue Magic army. The two headquarters are arranged in several cities in sequence.

Red headquarters, City 1, City 2 ,......, City n, blue headquarters

The command lines of the two armies make samurai. Samurai has five types: dragon, ninja, iceman, lion, and wolf. Each warrior has three attributes: ID, life value, and attack power.

The numbers of the warriors on both sides are counted from 1. The Nth warrior created by the Red Square, numbered n. Similarly, the n-th Warrior created by the blue side is numbered n.

A warrior has a life value when he was born.

On each hour, a warrior was born from the headquarters of both parties.

The Red Army Headquarters cyclically creates samurai in the order of iceman, lion, wolf, ninja, and dragon.

The blue-side headquarters cyclically creates samurai in the order of lion, dragon, ninja, iceman, and wolf.

To make a warrior, you need the life element.

 

 

To create a warrior whose initial life value is m, the life element in the command center will be reduced by m.

If the element of life in the headquarters is insufficient to create a samurai that should be made in order, the Headquarters tries to create the next one. If none of the warriors can be made, the headquarters will stop manufacturing the warriors.

Given a given time, and the initial number of lifecycles of both sides of the headquarters, you are required to output all the events from 00:00 to the end of the dual headquarters to manufacture the samurai in order.

There are two types of events. The output example is as follows:

1) samurai was born

Output example: 004 blue lion 5 born with strength 5, 2 lion in red headquarter

It indicates that at four o'clock, the Blue Magic lion warrior numbered 5 was born, and its life value was 5. After the birth, there were two lion warriors in the Blue Magic command. (For the sake of simplicity, do not consider the plural form of words.) note that each time a new warrior is created, the total number of such samurai in the headquarters will be output.

2) The headquarters has stopped manufacturing samurai

Output example: 010 red headquarter stops making warriors

It indicates that at, the Red Square command stopped creating samurai.

When an event is output:

First, output in chronological order;

For events that occur at the same time, the red headquarters and the blue headquarters are output first.

Input

The first line is an integer representing the number of test data groups.

There are two rows of test data in each group.

The first row is an integer M. The meaning is that each command has M life elements (1 <= M <= 10000) at the beginning ).

Row 2: Five integers, which are the initial life values of dragon, ninja, iceman, lion, and wolf. They are all greater than 0 and less than or equal to 10000.

Output

For each group of test data, it is required to output all events from 00:00 to stop the manufacture of samurai at both sides of the headquarters.

For each group of test data, the output "Case: n" n is the number of the test data, starting from 1.

Next, output all events in the appropriate order and format. Each event starts with the time when the event occurred. The time is measured in hours and has three digits.

Sample input 123 1203 4 5 6 7 sample output 12345678910 Case: 1000 red iceman 1 born with strength 5, 1 iceman in red headquarter000 blue lion 1 born with strength 6, 1 lion in blue when red lion 2 born with strength 6, 1 lion in red headquarter001 blue dragon 2 born 3, 1 dragon in blue headquarter002 red wolf 3 born with strength, 1 wolf in red headquarter002 blue ninja 3 born with strength, 1 ninja in blue parse red headquarter stops making parse blue iceman 4 born with strength 5, 1 in blue headquarter004 blue headquarter stops making warriors
// The two military headquarters will make a warrior. Each of the five samurai, dragon ninja iceman lion wolf, has a number, health, and attack) three properties // The Red Square command creates a samurai in the order of iceman lion wolf ninja gradon // The blue square command creates a samurai in the order of lion gradon ninja iceman wolf // each produces a life value of M the life value of Samurai command should be reduced by m # include <iostream> # include <string> # include <iomanip> using namespace std; class hero {public: void set_health () {int h; cin> h; health = h;} int print_health () {return health;} private: int number; int health; int attack;} dragon, ninja, iceman, lion, wolf; int main () {int s; // Number of test groups cin> s; for (int I = 0; I <s; I ++) {int counter = 1; // The counter calculates the cycle int R, B generated by the hero; // The Red/blue Command's lifecycle int r [5], B [5]; // The Life Value of the five objects respectively int time = 0; // creation time int number = 1; string s_r [5] = {"iceman ", "lion", "wolf", "ninja", "dragon"}; // represents the object name in string s_ B [5] = {"lion", "dragon ", "ninja", "iceman", "wolf"}; cin> R; // enter the lifecycle B = R; // the lifecycle of the red-blue command is equal to dragon. set_health (); B [1] = r [4] = dragon. print_health (); ninja. set_health (); B [2] = r [3] = ninja. print_health (); iceman. set_health (); B [3] = r [0] = iceman. print_health (); lion. set_health (); B [0] = r [1] = lion. print_health (); wolf. set_health (); B [4] = r [2] = wolf. print_health (); cout <"case:" <I + 1 <endl; // input the lifecycle value of dragon ninja iceman lion wolf in sequence: int first_r = 1, first_ B = 1; // set the counter to control the last line of red/blue to only output the termination information once (int I = 0; I ++, time ++, number ++) {// cyclically output information about creating a hero R-= r [I]; if (R> = 0) {cout <setfill ('0') <setw (3) <time <"" <"red" <"" <s_r [I] <"<number <" born with strength "<r [i] <", "<counter <" "<s_r [I] <" in red headquarter "<endl;} else {if (first_r) {cout <setfill ('0') <setw (3) <time <"red headquarter stops making warriors" <endl; first_r = 0 ;}} b-= B [I]; if (B> = 0) {cout <setfill ('0') <setw (3) <time <"" <"blue" <"" <s_ B [I] <"<number <" born with strength "<B [i] <", "<counter <" "<s_ B [I] <" in blue headquarter "<endl;} else {if (first_ B) {cout <setfill ('0') <setw (3) <time <"bule headquarter stops making warriors" <endl; first_ B = 0 ;}} if (I = 4) {I =-1; counter ++;} if (first_r = 0 & first_ B = 0) {break ;}}} return 0 ;}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.