Problem K. Harbin Sausage

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)

Problem Description

Harbin Sausage is a kind of food usually made from ground meat, such as pork, beef along with salt and spices. The sausage has a history of over 100 years. Because the surface color of it is date red, people call it red sausage or Harbin sausage.
Harbin Sausage is reputable all over the country; it has now become the daily necessity for Harbin people to welcome friends and guests. The procedure is a little bit complicated. First, season the meat and put it in fridge for two or three days. Second, stir the meat with starch till it becomes meatballs. Third, fill the meat into the casing with special tools. Fourth, put it into a toaster oven for 1 hour at most. But the finished product is tasty. You can eat it directly, or match it with other dishes and Harbin beer.
(The above is quoted from http://www.chinatours.com/travel-guide/harbin/food/harbin-sausage.html)
A sausage can be regarded as a cylinder(圆柱体) attached with a hemisphere(半球) in each ends. The height of the cylinder is H, and the radius of both the cylinder and the hemispheres is R. You can see the following three views(三视图) to get a better understanding:

Now you are going to buy a sausage in the Mysterious Sausage Store. Given H and R (both are integers),please calculate how much you should pay. For convenience, the price of per unit volume(单位体积) is set to be 3/Pi(圆周率), and thus the answer is obviously a integer.

Input

One line containing H and R, 1 ≤ H, R ≤ 100

Output

One line containing the amount of money you should pay for this sausage

Sample Input

5 6

Sample Output

1404

题目解析:

实际上就是让我们求图片中三视图图形的体积,并且取pi = 3

#include <bits/stdc++.h> 
using namespace std;
const int pi = 3;
int main() {
    int H, R;
    cin >> H >> R;
    cout << (int)(4 * pow(R, 3) + pow(R, 2) * pi * H);
    return 0; 
}