CAKE - Birthday Cake
Adolf wants to send a cake to Blue Mary to celebrate her birthday. The cake looks like a tower which has M floors, each floor is a cylinder. The i-th cylinder counted from downside to upside has a integer height hi and a integer radius ri. These numbers fulfill the following two conditions:
- h1 > h2 > h3 > ... > hM
- r1 > r2 > r3 > ... > rM
Adolf is interested in minimising the area of the surface of the cake, except for the underside of the lowest cylinder. He needs your help because of his poor math knowledge.
Input
The very first line contains a integer number T. T test cases follow.
For each test case, the first line contains a single integer number N (N<=10000), the second line contains a single integer number M (M<=10). The cake must be made of M cylinders and its volume must be N*Pi (Pi = acos(-1.0)).
Output
For each test case, a single line containing a single integer S must be written to output. The required minimum area must be S*Pi.
Example
Sample Input: 1 100 2 Sample Output: 68
Added by: | Fudan University Problem Setters |
Date: | 2007-04-01 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: C99 ERL GOSU JS-RHINO |
Resource: | Chinese National Olympiad in Informatics 1999,Day 1; translated by Blue Mary |