Sphere Online Judge

SPOJ Problem Set (classical)

1452. Birthday Cake

Problem code: 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.

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:[Trichromatic] XilinX
Date:2007-04-01
Time limit:1s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All except: C99 strict ERL JS
Resource:Chinese National Olympiad in Informatics 1999,Day 1; translated by Blue Mary

hide comments
2011-01-27 10:33:15 vivek yadav
what is pi???
SPOJ © 2013 Sphere Research Labs. All Rights Reserved.