写得虚脱,然而欣慰的是,它挺短 【捂脸】,最后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 981000
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 headquarter000 blue lion 1 born with strength 6,1 lion in blue headquarter001 red lion 2 born with strength 6,1 lion in red headquarter001 blue dragon 2 born with strength 3,1 dragon in blue headquarter002 red wolf 3 born with strength 7,1 wolf in red headquarter002 blue ninja 3 born with strength 4,1 ninja in blue headquarter003 red headquarter stops making warriors003 blue iceman 4 born with strength 5,1 iceman in blue headquarter004 blue headquarter stops making warriorsCase:2000 red iceman 1 born with strength 5,1 iceman in red headquarter000 blue lion 1 born with strength 6,1 lion in blue headquarter001 red lion 2 born with strength 6,1 lion in red headquarter001 blue dragon 2 born with strength 3,1 dragon in blue headquarter002 red wolf 3 born with strength 7,1 wolf in red headquarter002 blue ninja 3 born with strength 14,1 ninja in blue headquarter003 red ninja 4 born with strength 14,1 ninja in red headquarter003 blue iceman 4 born with strength 5,1 iceman in blue headquarter004 red dragon 5 born with strength 3,1 dragon in red headquarter004 blue wolf 5 born with strength 7,1 wolf in blue headquarter005 red iceman 6 born with strength 5,2 iceman in red headquarter005 blue dragon 6 born with strength 3,2 dragon in blue headquarter006 red headquarter stops making warriors006 blue headquarter stops making warriorsCase:3000 red headquarter stops making warriors000 blue headquarter stops making warriorsCase:4000 red iceman 1 born with strength 30,1 iceman in red headquarter000 blue lion 1 born with strength 40,1 lion in blue headquarter001 red lion 2 born with strength 40,1 lion in red headquarter001 blue dragon 2 born with strength 10,1 dragon in blue headquarter002 red ninja 3 born with strength 20,1 ninja in red headquarter002 blue ninja 3 born with strength 20,1 ninja in blue headquarter003 red dragon 4 born with strength 10,1 dragon in red headquarter003 blue iceman 4 born with strength 30,1 iceman in blue headquarter004 red headquarter stops making warriors004 blue headquarter stops making warriorsCase:5000 red iceman 1 born with strength 300,1 iceman in red headquarter000 blue lion 1 born with strength 60,1 lion in blue headquarter001 red lion 2 born with strength 60,1 lion in red headquarter001 blue dragon 2 born with strength 20,1 dragon in blue headquarter002 red ninja 3 born with strength 3,1 ninja in red headquarter002 blue ninja 3 born with strength 3,1 ninja in blue headquarter003 red dragon 4 born with strength 20,1 dragon in red headquarter003 blue iceman 4 born with strength 300,1 iceman in blue headquarter004 red ninja 5 born with strength 3,2 ninja in red headquarter004 blue ninja 5 born with strength 3,2 ninja in blue headquarter005 red ninja 6 born with strength 3,3 ninja in red headquarter005 blue ninja 6 born with strength 3,3 ninja in blue headquarter006 red ninja 7 born with strength 3,4 ninja in red headquarter006 blue ninja 7 born with strength 3,4 ninja in blue headquarter007 red ninja 8 born with strength 3,5 ninja in red headquarter007 blue ninja 8 born with strength 3,5 ninja in blue headquarter008 red ninja 9 born with strength 3,6 ninja in red headquarter008 blue ninja 9 born with strength 3,6 ninja in blue headquarter009 red headquarter stops making warriors009 blue headquarter stops making warriorsCase:6000 red iceman 1 born with strength 47,1 iceman in red headquarter000 blue dragon 1 born with strength 332,1 dragon in blue headquarter001 red wolf 2 born with strength 83,1 wolf in red headquarter001 blue ninja 2 born with strength 90,1 ninja in blue headquarter002 red ninja 3 born with strength 90,1 ninja in red headquarter002 blue iceman 3 born with strength 47,1 iceman in blue headquarter003 red dragon 4 born with strength 332,1 dragon in red headquarter003 blue wolf 4 born with strength 83,1 wolf in blue headquarter004 red iceman 5 born with strength 47,2 iceman in red headquarter004 blue dragon 5 born with strength 332,2 dragon in blue headquarter005 red wolf 6 born with strength 83,2 wolf in red headquarter005 blue ninja 6 born with strength 90,2 ninja in blue headquarter006 red ninja 7 born with strength 90,2 ninja in red headquarter006 blue headquarter stops making warriors007 red iceman 8 born with strength 47,3 iceman in red headquarter008 red wolf 9 born with strength 83,3 wolf in red headquarter009 red ninja 10 born with strength 90,3 ninja in red headquarter010 red headquarter stops making warriorsCase:7000 red iceman 1 born with strength 6,1 iceman in red headquarter000 blue lion 1 born with strength 70,1 lion in blue headquarter001 red lion 2 born with strength 70,1 lion in red headquarter001 blue dragon 2 born with strength 200,1 dragon in blue headquarter002 red wolf 3 born with strength 20,1 wolf in red headquarter002 blue ninja 3 born with strength 400,1 ninja in blue headquarter003 red ninja 4 born with strength 400,1 ninja in red headquarter003 blue iceman 4 born with strength 6,1 iceman in blue headquarter004 red dragon 5 born with strength 200,1 dragon in red headquarter004 blue wolf 5 born with strength 20,1 wolf in blue headquarter005 red iceman 6 born with strength 6,2 iceman in red headquarter005 blue lion 6 born with strength 70,2 lion in blue headquarter006 red lion 7 born with strength 70,2 lion in red headquarter006 blue dragon 7 born with strength 200,2 dragon in blue headquarter007 red wolf 8 born with strength 20,2 wolf in red headquarter007 blue ninja 8 born with strength 400,2 ninja in blue headquarter008 red ninja 9 born with strength 400,2 ninja in red headquarter008 blue iceman 9 born with strength 6,2 iceman in blue headquarter009 red dragon 10 born with strength 200,2 dragon in red headquarter009 blue wolf 10 born with strength 20,2 wolf in blue headquarter010 red iceman 11 born with strength 6,3 iceman in red headquarter010 blue lion 11 born with strength 70,3 lion in blue headquarter011 red lion 12 born with strength 70,3 lion in red headquarter011 blue dragon 12 born with strength 200,3 dragon in blue headquarter012 red wolf 13 born with strength 20,3 wolf in red headquarter012 blue ninja 13 born with strength 400,3 ninja in blue headquarter013 red ninja 14 born with strength 400,3 ninja in red headquarter013 blue iceman 14 born with strength 6,3 iceman in blue headquarter014 red dragon 15 born with strength 200,3 dragon in red headquarter014 blue wolf 15 born with strength 20,3 wolf in blue headquarter015 red iceman 16 born with strength 6,4 iceman in red headquarter015 blue lion 16 born with strength 70,4 lion in blue headquarter016 red lion 17 born with strength 70,4 lion in red headquarter016 blue dragon 17 born with strength 200,4 dragon in blue headquarter017 red wolf 18 born with strength 20,4 wolf in red headquarter017 blue ninja 18 born with strength 400,4 ninja in blue headquarter018 red ninja 19 born with strength 400,4 ninja in red headquarter018 blue iceman 19 born with strength 6,4 iceman in blue headquarter019 red dragon 20 born with strength 200,4 dragon in red headquarter019 blue wolf 20 born with strength 20,4 wolf in blue headquarter020 red iceman 21 born with strength 6,5 iceman in red headquarter020 blue lion 21 born with strength 70,5 lion in blue headquarter021 red lion 22 born with strength 70,5 lion in red headquarter021 blue dragon 22 born with strength 200,5 dragon in blue headquarter022 red wolf 23 born with strength 20,5 wolf in red headquarter022 blue ninja 23 born with strength 400,5 ninja in blue headquarter023 red ninja 24 born with strength 400,5 ninja in red headquarter023 blue iceman 24 born with strength 6,5 iceman in blue headquarter024 red dragon 25 born with strength 200,5 dragon in red headquarter024 blue wolf 25 born with strength 20,5 wolf in blue headquarter025 red iceman 26 born with strength 6,6 iceman in red headquarter025 blue lion 26 born with strength 70,6 lion in blue headquarter026 red lion 27 born with strength 70,6 lion in red headquarter026 blue dragon 27 born with strength 200,6 dragon in blue headquarter027 red wolf 28 born with strength 20,6 wolf in red headquarter027 blue ninja 28 born with strength 400,6 ninja in blue headquarter028 red ninja 29 born with strength 400,6 ninja in red headquarter028 blue iceman 29 born with strength 6,6 iceman in blue headquarter029 red dragon 30 born with strength 200,6 dragon in red headquarter029 blue wolf 30 born with strength 20,6 wolf in blue headquarter030 red iceman 31 born with strength 6,7 iceman in red headquarter030 blue lion 31 born with strength 70,7 lion in blue headquarter031 red lion 32 born with strength 70,7 lion in red headquarter031 blue dragon 32 born with strength 200,7 dragon in blue headquarter032 red wolf 33 born with strength 20,7 wolf in red headquarter032 blue ninja 33 born with strength 400,7 ninja in blue headquarter033 red ninja 34 born with strength 400,7 ninja in red headquarter033 blue iceman 34 born with strength 6,7 iceman in blue headquarter034 red dragon 35 born with strength 200,7 dragon in red headquarter034 blue wolf 35 born with strength 20,7 wolf in blue headquarter035 red iceman 36 born with strength 6,8 iceman in red headquarter035 blue lion 36 born with strength 70,8 lion in blue headquarter036 red lion 37 born with strength 70,8 lion in red headquarter036 blue iceman 37 born with strength 6,8 iceman in blue headquarter037 red wolf 38 born with strength 20,8 wolf in red headquarter037 blue wolf 38 born with strength 20,8 wolf in blue headquarter038 red iceman 39 born with strength 6,9 iceman in red headquarter038 blue iceman 39 born with strength 6,9 iceman in blue headquarter039 red wolf 40 born with strength 20,9 wolf in red headquarter039 blue wolf 40 born with strength 20,9 wolf in blue headquarter040 red iceman 41 born with strength 6,10 iceman in red headquarter040 blue iceman 41 born with strength 6,10 iceman in blue headquarter041 red headquarter stops making warriors041 blue headquarter stops making warriors
#include#include #include #include 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< >n; int stop; for(int i=0;i >M; for(r=0;r<5;r++){ cin>>Warrior[r]; } MIN = Warrior[0]; for(r=1;r<5;r++){ if(Warrior[r]