魔兽1 -备战
写得虚脱,然而欣慰的是,它挺短 【捂脸】,最后debug,发现竟然是Case 首字母忘记大写......这告诉我们一个道理,要看清题目,注意细节 qwq
随手奉上测试数据~ 如果都正确应该就没问题了!
//input
7
20
3 4 5 6 7
40
3 14 5 6 7
30
40 50 60 70 80
100
10 20 30 40 50
400
20 3 300 60 98
1000
332 90 47 8989 83
5000
200 400 6 70 20
//output:
Case:1
000 red iceman 1 born with strength 5,1 iceman in red headquarter
000 blue lion 1 born with strength 6,1 lion in blue headquarter
001 red lion 2 born with strength 6,1 lion in red headquarter
001 blue dragon 2 born with strength 3,1 dragon in blue headquarter
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
003 red headquarter stops making warriors
003 blue iceman 4 born with strength 5,1 iceman in blue headquarter
004 blue headquarter stops making warriors
Case:2
000 red iceman 1 born with strength 5,1 iceman in red headquarter
000 blue lion 1 born with strength 6,1 lion in blue headquarter
001 red lion 2 born with strength 6,1 lion in red headquarter
001 blue dragon 2 born with strength 3,1 dragon in blue headquarter
002 red wolf 3 born with strength 7,1 wolf in red headquarter
002 blue ninja 3 born with strength 14,1 ninja in blue headquarter
003 red ninja 4 born with strength 14,1 ninja in red headquarter
003 blue iceman 4 born with strength 5,1 iceman in blue headquarter
004 red dragon 5 born with strength 3,1 dragon in red headquarter
004 blue wolf 5 born with strength 7,1 wolf in blue headquarter
005 red iceman 6 born with strength 5,2 iceman in red headquarter
005 blue dragon 6 born with strength 3,2 dragon in blue headquarter
006 red headquarter stops making warriors
006 blue headquarter stops making warriors
Case:3
000 red headquarter stops making warriors
000 blue headquarter stops making warriors
Case:4
000 red iceman 1 born with strength 30,1 iceman in red headquarter
000 blue lion 1 born with strength 40,1 lion in blue headquarter
001 red lion 2 born with strength 40,1 lion in red headquarter
001 blue dragon 2 born with strength 10,1 dragon in blue headquarter
002 red ninja 3 born with strength 20,1 ninja in red headquarter
002 blue ninja 3 born with strength 20,1 ninja in blue headquarter
003 red dragon 4 born with strength 10,1 dragon in red headquarter
003 blue iceman 4 born with strength 30,1 iceman in blue headquarter
004 red headquarter stops making warriors
004 blue headquarter stops making warriors
Case:5
000 red iceman 1 born with strength 300,1 iceman in red headquarter
000 blue lion 1 born with strength 60,1 lion in blue headquarter
001 red lion 2 born with strength 60,1 lion in red headquarter
001 blue dragon 2 born with strength 20,1 dragon in blue headquarter
002 red ninja 3 born with strength 3,1 ninja in red headquarter
002 blue ninja 3 born with strength 3,1 ninja in blue headquarter
003 red dragon 4 born with strength 20,1 dragon in red headquarter
003 blue iceman 4 born with strength 300,1 iceman in blue headquarter
004 red ninja 5 born with strength 3,2 ninja in red headquarter
004 blue ninja 5 born with strength 3,2 ninja in blue headquarter
005 red ninja 6 born with strength 3,3 ninja in red headquarter
005 blue ninja 6 born with strength 3,3 ninja in blue headquarter
006 red ninja 7 born with strength 3,4 ninja in red headquarter
006 blue ninja 7 born with strength 3,4 ninja in blue headquarter
007 red ninja 8 born with strength 3,5 ninja in red headquarter
007 blue ninja 8 born with strength 3,5 ninja in blue headquarter
008 red ninja 9 born with strength 3,6 ninja in red headquarter
008 blue ninja 9 born with strength 3,6 ninja in blue headquarter
009 red headquarter stops making warriors
009 blue headquarter stops making warriors
Case:6
000 red iceman 1 born with strength 47,1 iceman in red headquarter
000 blue dragon 1 born with strength 332,1 dragon in blue headquarter
001 red wolf 2 born with strength 83,1 wolf in red headquarter
001 blue ninja 2 born with strength 90,1 ninja in blue headquarter
002 red ninja 3 born with strength 90,1 ninja in red headquarter
002 blue iceman 3 born with strength 47,1 iceman in blue headquarter
003 red dragon 4 born with strength 332,1 dragon in red headquarter
003 blue wolf 4 born with strength 83,1 wolf in blue headquarter
004 red iceman 5 born with strength 47,2 iceman in red headquarter
004 blue dragon 5 born with strength 332,2 dragon in blue headquarter
005 red wolf 6 born with strength 83,2 wolf in red headquarter
005 blue ninja 6 born with strength 90,2 ninja in blue headquarter
006 red ninja 7 born with strength 90,2 ninja in red headquarter
006 blue headquarter stops making warriors
007 red iceman 8 born with strength 47,3 iceman in red headquarter
008 red wolf 9 born with strength 83,3 wolf in red headquarter
009 red ninja 10 born with strength 90,3 ninja in red headquarter
010 red headquarter stops making warriors
Case:7
000 red iceman 1 born with strength 6,1 iceman in red headquarter
000 blue lion 1 born with strength 70,1 lion in blue headquarter
001 red lion 2 born with strength 70,1 lion in red headquarter
001 blue dragon 2 born with strength 200,1 dragon in blue headquarter
002 red wolf 3 born with strength 20,1 wolf in red headquarter
002 blue ninja 3 born with strength 400,1 ninja in blue headquarter
003 red ninja 4 born with strength 400,1 ninja in red headquarter
003 blue iceman 4 born with strength 6,1 iceman in blue headquarter
004 red dragon 5 born with strength 200,1 dragon in red headquarter
004 blue wolf 5 born with strength 20,1 wolf in blue headquarter
005 red iceman 6 born with strength 6,2 iceman in red headquarter
005 blue lion 6 born with strength 70,2 lion in blue headquarter
006 red lion 7 born with strength 70,2 lion in red headquarter
006 blue dragon 7 born with strength 200,2 dragon in blue headquarter
007 red wolf 8 born with strength 20,2 wolf in red headquarter
007 blue ninja 8 born with strength 400,2 ninja in blue headquarter
008 red ninja 9 born with strength 400,2 ninja in red headquarter
008 blue iceman 9 born with strength 6,2 iceman in blue headquarter
009 red dragon 10 born with strength 200,2 dragon in red headquarter
009 blue wolf 10 born with strength 20,2 wolf in blue headquarter
010 red iceman 11 born with strength 6,3 iceman in red headquarter
010 blue lion 11 born with strength 70,3 lion in blue headquarter
011 red lion 12 born with strength 70,3 lion in red headquarter
011 blue dragon 12 born with strength 200,3 dragon in blue headquarter
012 red wolf 13 born with strength 20,3 wolf in red headquarter
012 blue ninja 13 born with strength 400,3 ninja in blue headquarter
013 red ninja 14 born with strength 400,3 ninja in red headquarter
013 blue iceman 14 born with strength 6,3 iceman in blue headquarter
014 red dragon 15 born with strength 200,3 dragon in red headquarter
014 blue wolf 15 born with strength 20,3 wolf in blue headquarter
015 red iceman 16 born with strength 6,4 iceman in red headquarter
015 blue lion 16 born with strength 70,4 lion in blue headquarter
016 red lion 17 born with strength 70,4 lion in red headquarter
016 blue dragon 17 born with strength 200,4 dragon in blue headquarter
017 red wolf 18 born with strength 20,4 wolf in red headquarter
017 blue ninja 18 born with strength 400,4 ninja in blue headquarter
018 red ninja 19 born with strength 400,4 ninja in red headquarter
018 blue iceman 19 born with strength 6,4 iceman in blue headquarter
019 red dragon 20 born with strength 200,4 dragon in red headquarter
019 blue wolf 20 born with strength 20,4 wolf in blue headquarter
020 red iceman 21 born with strength 6,5 iceman in red headquarter
020 blue lion 21 born with strength 70,5 lion in blue headquarter
021 red lion 22 born with strength 70,5 lion in red headquarter
021 blue dragon 22 born with strength 200,5 dragon in blue headquarter
022 red wolf 23 born with strength 20,5 wolf in red headquarter
022 blue ninja 23 born with strength 400,5 ninja in blue headquarter
023 red ninja 24 born with strength 400,5 ninja in red headquarter
023 blue iceman 24 born with strength 6,5 iceman in blue headquarter
024 red dragon 25 born with strength 200,5 dragon in red headquarter
024 blue wolf 25 born with strength 20,5 wolf in blue headquarter
025 red iceman 26 born with strength 6,6 iceman in red headquarter
025 blue lion 26 born with strength 70,6 lion in blue headquarter
026 red lion 27 born with strength 70,6 lion in red headquarter
026 blue dragon 27 born with strength 200,6 dragon in blue headquarter
027 red wolf 28 born with strength 20,6 wolf in red headquarter
027 blue ninja 28 born with strength 400,6 ninja in blue headquarter
028 red ninja 29 born with strength 400,6 ninja in red headquarter
028 blue iceman 29 born with strength 6,6 iceman in blue headquarter
029 red dragon 30 born with strength 200,6 dragon in red headquarter
029 blue wolf 30 born with strength 20,6 wolf in blue headquarter
030 red iceman 31 born with strength 6,7 iceman in red headquarter
030 blue lion 31 born with strength 70,7 lion in blue headquarter
031 red lion 32 born with strength 70,7 lion in red headquarter
031 blue dragon 32 born with strength 200,7 dragon in blue headquarter
032 red wolf 33 born with strength 20,7 wolf in red headquarter
032 blue ninja 33 born with strength 400,7 ninja in blue headquarter
033 red ninja 34 born with strength 400,7 ninja in red headquarter
033 blue iceman 34 born with strength 6,7 iceman in blue headquarter
034 red dragon 35 born with strength 200,7 dragon in red headquarter
034 blue wolf 35 born with strength 20,7 wolf in blue headquarter
035 red iceman 36 born with strength 6,8 iceman in red headquarter
035 blue lion 36 born with strength 70,8 lion in blue headquarter
036 red lion 37 born with strength 70,8 lion in red headquarter
036 blue iceman 37 born with strength 6,8 iceman in blue headquarter
037 red wolf 38 born with strength 20,8 wolf in red headquarter
037 blue wolf 38 born with strength 20,8 wolf in blue headquarter
038 red iceman 39 born with strength 6,9 iceman in red headquarter
038 blue iceman 39 born with strength 6,9 iceman in blue headquarter
039 red wolf 40 born with strength 20,9 wolf in red headquarter
039 blue wolf 40 born with strength 20,9 wolf in blue headquarter
040 red iceman 41 born with strength 6,10 iceman in red headquarter
040 blue iceman 41 born with strength 6,10 iceman in blue headquarter
041 red headquarter stops making warriors
041 blue headquarter stops making warriors
#include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> using namespace std; class Headquarter{ char NAME[5]; int Wlife[5]; char WName[5][10]; int WNum[5]={0}; int WRemain[5]={0}; int Tolife; int t=0,Min; int r=0; int num=0; int* pw=Wlife; int* pw1=Wlife; public: int stop=0,d=0; Headquarter(int* W_life,char* W_name[],int Tol_life,char* name,int n){ Min = n; strcpy(NAME,name); Tolife=Tol_life; for(int i=0;i<5;i++){ Wlife[i]=W_life[i]; strcpy(WName[i],W_name[i]); } } void begin(){ if(Tolife>=Min){ for(r=0;r<5;r++){ if(pw-pw1>4){ pw -=5; } if(Tolife>=*pw){ Tolife -= *pw; num++; WNum[pw-pw1]++; WRemain[pw-pw1]++; print1(); t++; pw++; break; } pw++; } } else{ if(d==0){ print2(); } } } void print1(){ int r = pw-pw1; cout.fill('0'); cout.width(3); cout<<t; cout.fill(); cout.width(); cout<<" "<<NAME<<" "<<WName[r]<<" "<<num<<" born with strength "<<Wlife[r]<<","<<WRemain[r]<<" "<<WName[r]<<" in "<<NAME<<" headquarter"<<endl; } void print2(){ cout.fill('0'); cout.width(3); cout<<t; cout.fill(); cout.width(); cout<<" "<<NAME<<" "<<"headquarter stops making warriors"<<endl; d=1; } }; int main(){ int MIN; int r; int n; int M; int Warrior[5];//dragon,ninja,iceman,lion,wolf cin>>n; int stop; for(int i=0;i<n;i++){ cin>>M; for(r=0;r<5;r++){ cin>>Warrior[r]; } MIN = Warrior[0]; for(r=1;r<5;r++){ if(Warrior[r]<MIN){ MIN=Warrior[r]; } } int Warrior_r[5]={Warrior[2],Warrior[3],Warrior[4],Warrior[1],Warrior[0]}; int Warrior_b[5]={Warrior[3],Warrior[0],Warrior[1],Warrior[2],Warrior[4]}; char* W_Name_r[]={"iceman","lion","wolf","ninja","dragon"}; char* W_Name_b[]={"lion","dragon","ninja","iceman","wolf"}; Headquarter r(Warrior_r,W_Name_r,M,"red",MIN); Headquarter b(Warrior_b,W_Name_b,M,"blue",MIN); cout<<"Case:"<<i+1<<endl; while((r.d==1&&b.d==1)!=1){ r.begin(); b.begin(); } } }