FJNUOJ1156

1156: Fat Brother’s Gorehowl
Time Limit: 1000 MS Memory Limit: 257792 KB
64-bit interger IO format: %lld Java class name: Main

Submit Status Discuss
Description
Fat Brother is a Great warrior(战士) and he has a powerful weapons named “Gorehowl”. Firstly it can cause 7 damage points to the other side, but it will decrease 1 damage points after one attack.

One day, Fat Brother meet N monsters, but he only take his “Gorehowl”.

Each monster has health points. When Fat Brother attacked a monster, the monster’s health points will decrease damage points of “Gorehowl”. If a monster’s health points less than or equal to zero, it die. Fat Brother must kill all monsters or he can’t get away from here. If he can kill all monster, he want to know least of times he should attack. If he can’t, he will choose go die.

Input
There are multiple test cases. The first line of input contains an integer T (T <= 50) indicating the number of test cases. For each test case:

The first line contains one integer N (1 <= N <= 100000) means number of monsters.

The next line contains N number Hi (1<= Hi <= 10) means monster’s health points.

Output
If Fat Brother can kill all monsters, output a number means least of times Fat Brother should attack. Otherwise output “Fat Brother choose go die”

Sample Input
3
2
12 6
1
28
1
29

Sample Output
3
7
Fat Brother choose go die

HINT

First
case, First attack first monster and it’s health points decrase to
5. Second attack second monster and it’s health points decrase to
0, it will die.Third attack first monster and it’s health points
decrase to 0, it will die. All monster die!

Second
case, attack first monster 7 times, and sum of damage points is 7 + 6
+ 5 + 4 + 3 + 2 + 1 = 28, kill all monster.

Third
case, Fat Brother can’t kill first monster, so he will choose go
die.

The test sample just explain problem, you can think the realy data is accord with the title’s description

暴搜一波可以AC 因为最多七只怪 循环最多就七个 七层 校赛现场这题没出好坑啊。。

#include "cstring"
#include "cstdio"
#include "iostream"
#include "string.h"
#include "stack"
int b[15];
int num;
int mark=-1;
bool check()
{
    bool m=true;
    for(int i=1;i<=num;i++)
    {
        if(b[i]>0)
        {
            m=false;
            break;
        }
    }
    return m;
}
void dfs(int ack)
{
    if(ack==0)
        return;
    for(int i=1;i<=num;i++)
    {
        if(b[i]<=0) continue;
        b[i]-=ack;
        if(check())
       {
          if(mark<ack)
         {
            mark=ack;
         }
       }
      else
            dfs(ack-1);
        b[i]+=ack;
    }
}
int main()
{
    int cas;
    scanf("%d",&cas);
    while(cas--)
    {
        mark=-1;
        int sum=0;
        scanf("%d",&num);
        int temp;
        if(num>7)
        {
            for(int i=1;i<=num;i++)
            scanf("%d",&temp);
            printf("Fat Brother choose go die\n");
            continue;
        }
        memset(b,0,sizeof(b));
        for(int i=1;i<=num;i++)
        {
            scanf("%d",&b[i]);
            sum+=b[i];
        }
        if(sum>28)
        {
            printf("Fat Brother choose go die\n");
            continue;
        }
        dfs(7);
        if(mark!=-1)
            printf("%d\n",8-mark);
        else
            printf("Fat Brother choose go die\n");
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值