1008.cpp

来自「ZOJ 动态规划算法题目入门与提高 源代码」· C++ 代码 · 共 23 行

CPP
23
字号
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
using namespace std;
int main(){
 // ifstream cin("in.txt");
  string n1,n2,s1,s2,s3;
  int h1,h2,d1,d2,c1,c2,hn1,hn2,p1,p2,v1,v2,t1,t2;
  while(cin>>n1>>h1>>d1>>c1>>hn1>>p1>>n2>>h2>>d2>>c2>>hn2>>p2){
	  v1=(p1-d2)*hn1; v2=(p2-d1)*hn2;
	  if(v1<1) v1=1;
	  if(v2<1) v2=1;
	  t1=h2/v1;
	  if(h2%v1!=0) t1+=1;
	  t2=h1/v2;
	  if(h1%v2!=0) t2+=1;
	  t1*=c1; t2*=c2;
	  if(t1<t2) cout<<n1<<" Survive!\n";
	  else if(t1>t2) cout<<n2<<" Survive!\n";
	  else cout<<"All Die!\n";
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?