若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1596: Is This Integration?

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,292

题目描述

The image below shows a square ABCD, where AB = BC = CD = DA = a. Four arcs are drawn taking the four vertexes A, B, C, D as centers and a as the radius. The arc that is drawn taking A as center starts at neighboring vertex B and ends at neighboring vertex D. All other arcs are drawn in a similar fashion. Regions of three different shapes are created in this fashion. You must determine the total area of these different shaped regions.

输入

Each line of the input file contains a floating-point number a indicating the side length of the square, where 0 <= a<= 10, 000.0. Input is terminated by end of file.

输出

For each test case, output on a single line the area of the different region types in the image above. Each floating point number should be printed with three digits after the decimal point. The first number of each case will denote the area of the striped region, the second number will denote the total area of the dotted regions, and the third number will denote the rest of the area.

样例输入

0.1
0.2
0.3


样例输出

0.003 0.005 0.002
0.013 0.020 0.007
0.028 0.046 0.016


参考代码

#include <stdio.h>
#include <math.h>
#define pi 3.141592653589793
//受不了 需要这么高精度的pi
int main() 
{
    double a;
    while(scanf("%lf",&a)==1) 
    {
        double x=a*a*(1+pi/3-sqrt(3));
        double y=a*a*(2*sqrt(3)+pi/3-4);
        double z=a*a*(4-sqrt(3)-2*pi/3);
        printf("%.3lf %.3lf %.3lfn",x,y,z);
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip Dreams孤独患者 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist