zoukankan      html  css  js  c++  java
  • 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 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
    

     题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3866

    几何题,加了外层之后可以看作是上下两个旋转体加上中间的圆柱体(半径为r+d),用积分算一下得到公式。

     1 #include <iostream>
     2 #include <cstring>
     3 #include <cstdio>
     4 #include <string>
     5 #include <iomanip>
     6 #include <cmath>
     7 using namespace std;
     8 #define pai acos(-1.0)
     9 int T;
    10 double r, h, d;
    11 int main(){
    12     scanf("%d", &T);
    13     while(T--){
    14         scanf("%lf%lf%lf", &r, &h, &d);
    15         double v, area;
    16         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;
    17         area = 2*(2*pai*d*d + 2*pai*r*d*asin(1.0)) + 2*pai*r*r + 2*pai*(r+d)*h;
    18         printf("%.12lf %.12lf
    ", v, area);
    19     }
    20     
    21     return 0;
    22 }
  • 相关阅读:
    linq to sql的性能和reader相比只是差一点点吗
    Win11删除右键菜单open in windows Terminal
    jdk1.8
    mvcc read view
    javascript 跨域双向通信方案,通过postMessage和window.name实现
    [原创]如何加载动态库、获取方法委托、卸载动态库
    awseks创建与使用
    aiops 调研
    consul调研
    机器学习调研
  • 原文地址:https://www.cnblogs.com/titicia/p/4422472.html
Copyright © 2011-2022 走看看