ZOJ - 3866 Cylinder Candy (数学,积分)

Cylinder Candy

Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %lld & %llu

Submit Status

Description

Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm and height h mm.

The candy center needs to be covered with a uniform coat of chocolate. The uniform coat of chocolate is d mm thick.

You are asked to calcualte the volume and the surface of the chocolate covered candy.

Input

There are multiple test cases. The first line of input contains an integer T(1≤ T≤ 1000) indicating the number of test cases. For each test case:

There are three integers rhd in one line. (1≤ rhd ≤ 100)

Output

For each case, print the volume and surface area of the candy in one line. The relative error should be less than 10-8.

Sample Input

2
1 1 1
1 3 5

Sample Output

32.907950527415 51.155135338077
1141.046818749128 532.235830206285

贴两个找到的代码,然后回家好好学微积分

#include <iostream>
#include <cmath>
#include <iomanip>
#define pi 4*atan(1.0)
using namespace std;
int main()
{
	int t,r,h,d;
    cin>>t;
    while(t--)
    {
    	cin>>r>>h>>d;
    	cout<<fixed<<setprecision(12)<<2*(2*d*d*d/3.0*pi+r*d*d*pi*pi/2)+pi*((r+d)*(r+d))*(h)+pi*(r*r)*2*d<<" ";
    	cout<<fixed<<setprecision(12)<<2*(pi*pi*d*r+2*pi*d*d)+2*pi*r*r+2*pi*(r+d)*h<<endl;
    }
	return 0;
} 
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
#define pai acos(-1.0)
int T;
double r, h, d;
int main(){
    scanf("%d", &T);
    while(T--){
        scanf("%lf%lf%lf", &r, &h, &d);
        double v, area;
        v = (pai*r*d*d*asin(1.0) + pai*(2.0/3.0*d*d*d + r*r*d))*2 + (r+d)*(r+d)*pai*h;
        area = 2*(2*pai*d*d + 2*pai*r*d*asin(1.0)) + 2*pai*r*r + 2*pai*(r+d)*h;
        printf("%.12lf %.12lf\n", v, area);
    }

    return 0;
}
时间: 2024-10-05 06:17:26

ZOJ - 3866 Cylinder Candy (数学,积分)的相关文章

ZOJ 3866 Cylinder Candy (浙大校赛+积分应用)

题目链接:ZOJ 3866 Cylinder Candy 题意:抽象出来就是求一个圆柱体外面加一层厚度为d的巧克力,求包装完这个立体图形的体积和表面积. 剖析: 以下是包装后的三视图: 图3 接下里就是积分了 2*V1是图3绕y轴的体积 V2是中间的半径为(r+d)的圆柱体积 S1是中间的半径为(r+d)的圆柱的表面积 S2是上下两个半径为r的圆的面积 S3是图3绕y轴的侧面积 附上旋转体的侧面积和体积求法: AC代码: #include <stdio.h> #include <math

ZOJ 3866 Cylinder Candy

Cylinder Candy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm and height h mm. The candy center

Cylinder Candy(积分+旋转体)

Cylinder Candy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm and height h mm. The candy center needs to

Cylinder Candy(积分)

Cylinder Candy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm and height h mm. The candy center needs to

2016 省热身赛 Cylinder Candy

Cylinder Candy Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm and height h mm

zoj 3866

G - Cylinder Candy Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3866 Description Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylin

UVA 11346 - Probability 数学积分

Consider rectangular coordinate system and point L(X, Y ) which is randomly chosen among all pointsin the area A which is de?ned in the following manner: A = {(x, y)|x ∈ [−a; a];y ∈ [−b; b]}. What isthe probability P that the area of a rectangle that

[ACM] sdut 2877 angry_birds_again_and_again (简单数学积分)

angry_birds_again_and_again Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 The problems called "Angry Birds" and "Angry Birds Again and Again" has been solved by many teams in the series of contest in 2011 Multi-University

poj 1543 &amp; HDU 1334 &amp; ZOJ 1331 Perfect Cubes(数学 暴力大法好)

题目链接:http://poj.org/problem?id=1543 Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > 2 there exist no integers a, b, c > 1 such that a^n = b^n + c^n, has remained elusively unproven. (A recent proof is believ