您的位置:首页 > 其它

FJNUOJ1156

2016-04-19 19:22 253 查看
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");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: