#include <bits/stdc++.h> using namespace std; int dragon=0,ninja=0,iceman=0,lion=0,wolf=0; int N; int life; class HQ{ public: char * color; int working=1; int life; int cp=0; //目前造到哪一个小兵,SEQUENCE中的下标 int sub=1; // 小兵的下标 char* na[5]={"dragon","ninja","iceman","lion","wolf"}; //小兵名字 int sequence[5]; //造兵顺序 int con[5]; //造每个兵的消耗 int num[5]={0,0,0,0,0}; //每种小兵的数量 HQ(int a[5],char *c){ memcpy(sequence,a,5*sizeof(int)); color=new char[10]; strcpy(color,c); } void init(int a,int b,int c,int d,int e){ con[0]=a; con[1]=b; con[2]=c; con[3]=d; con[4]=e; } void reset(){ working=1; for(int i=0;i<5;i++) num[i]=0; cp=0; sub=1; } void stop(){ if(!working){ cout<<color<<" headquarter stops making warriors"<<endl; } } void making(){ if(!working) return; int j; for(j=1;j<=5;j++){ if(life>=con[sequence[cp]]){ num[sequence[cp]]++; cout<<color<<" "<<na[sequence[cp]]<<" "<<sub<<" "<<"born with strength "<<con[sequence[cp]]; cout<<','<<num[sequence[cp]]<<' '<<na[sequence[cp]]<<" in "<<color<<" headquarter"<<endl; life-=con[sequence[cp]]; cp=(cp+1)%5; sub++; break; } cp=(cp+1)%5; } if(j==6){ working=0; stop(); } } }; int main() { int a[5]={2,3,4,1,0}; int b[5]={3,0,1,2,4}; HQ red(a,"red"),blue(b,"blue"); cin>>N; for(int i=1;i<=N;i++){ red.reset(); blue.reset(); cin>>life; red.life=life; blue.life=life; cin>>dragon>>ninja>>iceman>>lion>>wolf; red.init(dragon,ninja,iceman,lion,wolf); blue.init(dragon,ninja,iceman,lion,wolf); cout<<"Case:"<<i<<endl; for(int j=0;;j++){ if(red.working){ printf("%03d ",j); red.making(); } if(blue.working){ printf("%03d ",j); blue.making(); } if(!red.working&&!blue.working) break; } } return 0; }
emmm居然是在隔壁的咖啡厅里写出个大概的23333