HDU
来源:互联网 发布:ios映射软件 编辑:程序博客网 时间:2024/06/07 00:43
Hard problem
cjj is fun with math problem. One day he found a Olympic Mathematics problem for primary school students. It is too difficult for cjj. Can you solve it?
Give you the side length of the square L, you need to calculate the shaded area in the picture.
The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.
Give you the side length of the square L, you need to calculate the shaded area in the picture.
The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.
Input
Output
Sample Input
11
Sample Outpu
0.29
题意:
求 两块 黑色的阴影面积。
思路:
利用数学公式,一步一步化简。
已知三角形的三边长度,求面积 。用海伦公式 ==>SA
用余弦定理 ==> 角a 的度数 da
利用扇形的面积公式 ==>SA_B , 进而 ==> SB
用余弦定理和 换角公式 cos(pai - a) = -cosa ==> B的度数 dB
利用扇形的面积公式 ==>SB_C ,进而 ==>SC(是 1/4 的阴影面积)
AC代码:
#include <cstdio>#include <cmath>int main(){ int T; scanf("%d",&T); double L; double a,b,c,p; double SA,SA_B,SB,SB_C,SC; double db,cos_a ,dB; double ans; while(T--){ scanf("%lf",&L); // (1 <= L <= 10000) a = L; b = L/2; c = sqrt(2.0)*L/2; p = (a+b+c)/2; //半周长 SA = sqrt(p*(p-a)*(p-b)*(p-c) ); //db = acos( (a*a+c*c-b*b)/(2*a*c) );//化简之后是下面 db = ( acos( 1.25/sqrt(2.0) ) ); SA_B = db *a*a/2; SB = SA_B - SA; //cos_a = b*b+c*c-a*a)/(2*b*c); //dB = acos( -cos_a); //化简之后是下面 dB = acos( sqrt(2.0)/4 ); SB_C = dB *b*b/2; SC = SB_C - SB; ans = 4*SC; //最终结果 printf("%.2f\n",ans); } return 0;}
有不懂的,可以问我!
阅读全文
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- SpringIOC技术学习---day1
- leetcode 240. Search a 2D Matrix II
- Sensor sc2235 Porting
- hdu6112 今夕何夕
- Android系统堆内存限制浅析
- HDU
- Web应用程序简介
- leetcode 222. Count Complete Tree Nodes
- MYSQL 最近知识总结(5)
- C++的基础知识(三)--STL基础
- UriMatcher类使用介绍
- 经典实例
- KMP两种写法以及AC自动机失配数组间的区别
- maven 创建多模块备忘(1)之搭建结构