HDU 1714 math
2015-07-22 17:42
260 查看
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
int n;
double a, b, px, py;
cin >> n;
while(n--)
{
cin >> a >> b >> px >> py;
if (py < 0)
py = -py;
else if (py == 0)
{
cout << setprecision(2) << 0.00 << endl;
continue;
}
double jx, jy, k;
k = py * 1.0 / px;
jx = (a * a * b * b) / (b * b + a * a * k * k);
jx = sqrt(jx);
jy = k * jx;
double angle = atan(py * 1.0 / px);
double s1 = (0.5 * a * b * angle) - (0.25 * a * b * sin(2 * angle));
double s2 = 0.5 * jx * jy;
double s = s1 + s2;
cout << setprecision(2) << s << endl;
}
return 0;
}
#include<string.h>
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
int n;
double a, b, px, py;
cin >> n;
while(n--)
{
cin >> a >> b >> px >> py;
if (py < 0)
py = -py;
else if (py == 0)
{
cout << setprecision(2) << 0.00 << endl;
continue;
}
double jx, jy, k;
k = py * 1.0 / px;
jx = (a * a * b * b) / (b * b + a * a * k * k);
jx = sqrt(jx);
jy = k * jx;
double angle = atan(py * 1.0 / px);
double s1 = (0.5 * a * b * angle) - (0.25 * a * b * sin(2 * angle));
double s2 = 0.5 * jx * jy;
double s = s1 + s2;
cout << setprecision(2) << s << endl;
}
return 0;
}
相关文章推荐
- ***PHP请求服务curl以及json的解析
- Linux日常管理-复习练习
- BZOJ 1531: [POI2005]Bank notes( 背包 )
- transform应用详解
- 微信平台抽奖算法总结-再也不用怕奖品被提前抢光
- 内存管理
- Linux RedHat 6.4 MySQL5.6源码包安装
- Redis复制与可扩展集群搭建
- 傅立叶外推算法的python实现和缺点
- MSSQL数据库邮件配置
- Virtual、虚函数、指针、 引用、基类、父类
- 2015年需要了解的前端框架和语言
- 【iOS开发系列】用简单工厂模式理解OC反射机制
- 2015年需要了解的前端框架和语言
- after Normal block(#47) at 0x001D3908 错误的一次解决经历
- IP地址划分类型和子网划分
- 11111111111
- Invalid number of data directories in NT header
- debian 切换默认桌面命令
- Linux中各种环境变量的理解