Hard problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 38    Accepted Submission(s): 23

Problem Description
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.

 
Input
The first line contains a integer T(1<=T<=10000), means the number of the test case. Each case contains one line with integer l(1<=l<=10000).
 
Output
For each test case, print one line, the shade area in the picture. The answer is round to two digit.
 
Sample Input
1
1
 
Sample Output
0.29
 
Author
BUPT
 
求大圆,小圆面积的交x,2*(小圆面积-x)就是答案。
/* ***********************************************
Author :guanjun
Created Time :2016/8/18 12:33:04
File Name :p1002.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const long double PI=acos(-1.0);
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
struct Round{
double x,y;
double r;
double K(double x){
return x*x;
}
double Dis(Round a,Round b){
return sqrt(K(a.x-b.x)+K(a.y-b.y));
}
double Intersection_area(Round a,Round b){
double dis=Dis(a,b);
if(a.r==||b.r==||dis>=a.r+b.r)return ;
else if(dis<=fabs(a.r-b.r))return PI*K(min(a.r,b.r));
else{
double angA=*acos( (K(a.r)+K(dis)-K(b.r))/(*a.r*dis) );
double angB=*acos( (K(b.r)+K(dis)-K(a.r))/(*b.r*dis) );
double areaA=K(a.r)*(angA-sin(angA))/;
double areaB=K(b.r)*(angB-sin(angB))/;
return areaA+areaB;
}
}
}a,b;
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
cin>>n;
double l;
while(n--){
scanf("%lf",&l);
a.x=l/.,a.y=l/.,a.r=l/.;
b.x=l,b.y=.,b.r=l;
double ans=PI*l*l/.-*a.Intersection_area(a,b);
printf("%.2f\n",ans);
}
return ;
}

最新文章

  1. Sql数据库查询当前环境有无死锁
  2. django 的模板语言
  3. BZOJ3740 : pku2842 N-dimension Matching N维匹配
  4. 教官的游戏(codevs 2793)
  5. PR 创建
  6. jsonp跨域js
  7. C#中调用WIN32的API
  8. Windows Server 2003 安装Sql Server 2005 问题处理
  9. [Cocos2d-x开发问题-3] cocos2dx动画Animation介绍
  10. 聊聊pthread_cond_wait的虚假唤醒
  11. SpringMVC 表单验证
  12. 2016-wing的年度总结
  13. C++示例
  14. Vue 组件&amp;组件之间的通信 之 单向数据流
  15. (一)flask-sqlalchemy的安装和配置
  16. mongoose findByIdAndUpdate不执行的解决方法
  17. MFC字体样式和颜色设置
  18. 架构之路:nginx与IIS服务器搭建集群实现负载均衡(三)
  19. sFlow-rt安装部署
  20. c# 连接mysql配置config,不用装net connector

热门文章

  1. 散列(hash)
  2. 子集和问题 - 回溯&amp;搜索
  3. 洛谷——P1073 最优贸易
  4. 为什么map对象不能使用stl中的sort函数
  5. Codeforces 989C - A Mist of Florescence
  6. Springboot druid监控配置
  7. 教你 Shiro 整合 SpringBoot,避开各种坑
  8. POJ 1226 Substrings
  9. jquery动态为个span,input,div,等标签赋值的方法总结,js动态隐藏div
  10. JavaMelody开源系统性能监控