2302Eat cheese

2302   Eat cheese

题目描述

Tom came up with a terrible way to catch Jerry. He set a trap in front of Jerry's house.And there is some cheese in the trap. This cheese is a magic cheese, and if you eat one x cheese, Jerry's weight will increase by x. Then, once Jerry starts eating cheese, the trap kicks in. And it catches Jerry when he stops eating cheese. But there's a problem. The trap doesn't catch Jerry when he weighs a perfect square. Of course the clever Jerry wanted to eat cheese as much as possible. Suppose Jerry's weight started from zero. Now, is there any way you can help him eat as much cheese as possible?

输入格式:

The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case contains one integers N which is the number of cheese.

The second line have n integers w which is the weight of cheese

T <= 20

1<= n <= 20

1<= w <= 1,000,000

输出格式:

For each case, output the maximum number of cheese you can eat in a line.

输入样例 复制
2
2
1 1
3
1 2 2
输出样例 复制
1
2

说明

14
73
通过提交
时空限制1000ms/128mb
题目来源
评测方式在线评测
题目类型
难        度