2003 Canadian Computing Competition, Stage 2

Day 1, Problem 2: Concentration

Stan has a deck of N Concentration Cards. He wants to lay the cards edge-to-edge to form a filled rectangle with minimal perimeter. Each card is a rectangle with dimensions W mm. by H mm.

Figure 1: Concentration Cards
Figure 1: Concentration Cards

Input

The first line of input contains C, the number of test cases. For each case there is an additional line containing N, W, H, each a positive integer not exceeding 1000.

Output

Your program should produce one line of output per case, giving the minimal perimeter.

Sample Input

3
3 300 400
4 400 300
7 300 400

Sample Output

2600
2800
3800

All Submissions
Best Solutions


Point Value: 15
Time Limit: 2.00s
Memory Limit: 16M
Added: Dec 28, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's quiet in here...