Pk武林盟主(C++)

#include<iostream>
#include<cmath>
#include<iomanip>
#include<windows.h>
using namespace std;

struct node
{
 int hp1;
 int ap1;
 int hp2;
 int ap2;
}seq[1<<16];

int front = 0;
int rear = 0;
 
void push(node n)
{
 seq[rear].hp1 = n.hp1;
 seq[rear].ap1 = n.ap1;
 seq[rear].hp2 = n.hp2;
 seq[rear].ap2 = n.ap2;
 rear++;
}
void pop(node &n)
{
 n.hp1 = seq[front].hp1;
 n.ap1 = seq[front].ap1;
 n.hp2 = seq[front].hp2;
 n.ap2 = seq[front].ap2;
 front++;   
}


int main()
{
 int floor = 0;
 float sum = 0;
 int count[1<<15] = {0};
 count[0] = 1;
 node n,t;
 cin>>n.hp1>>n.ap1>>n.hp2>>n.ap2;
 if((n.hp1<1||n.hp1>32767)&&(n.ap1<1||n.ap1>32767)&&(n.hp2<1||n.hp2>32767)&&(n.ap2<1||n.ap2>32767))
  return 0;
 push(n);
 while(front!=rear)
 {
  pop(n);
  if(count[floor] == 0)
   floor++;
  count[floor]--;
  if(n.hp1<=0)
   ;
  else if(n.hp2<=0)
  {
   sum += 1.0/pow(2,(double)floor);
  }else
  {
   count[floor+1] = count[floor+1] + 2;
   t.hp1 = n.hp1 - n.ap2;
   t.ap1 = n.ap1;
   t.hp2 = n.hp2;
   t.ap2 = n.ap2;
   push(t);
   t.hp1 = n.hp1;
   t.hp2 = n.hp2 - n.ap1;
   push(t);
  } 
 }
 cout<<setprecision(4)<<setiosflags(ios::fixed)<<sum<<endl;
 return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值