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 }
  • 相关阅读:
    python常用包官网及包的安装方法
    二进制安装mysql-5.7.26
    ufw防火墙规则不生效
    Zabbix 3.0 配置企业微信报警(配置zabbix-web)
    Zabbix 3.0 配置企业微信报警(注册---测试)
    阿里云盾AliYunDun服务IO超高
    zabbix详解
    ntp时间同步
    zabbix解决中文乱码
    ssh登录服务器提示错误no hostkey alg
  • 原文地址:https://www.cnblogs.com/titicia/p/4422472.html
Copyright © 2011-2022 走看看