HDU 1071 - The area
2015-07-22 11:22
337 查看
HDU 1071 - The area
Easy Math Problems -_-Output the area of the shadow area.
The consuming key point exsists in how to caculate a, b, c.
kind of easy, as long as you just go ahead without considering the complexity of your expression.
#include<iostream> #include<cstdio> #include<cmath> using namespace std; void fMain() { double x1, y1, x2, y2, x3, y3; double a, b, c, k, b1, s; //y=a*x*x+b*x+c; //y=k*x+b2; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; k = (y3 - y2) / (x3 - x2); b1 = y3 - k * x3; a = ((x2 - x1) * (y3 - y2) - (x3 - x2) * (y2 - y1)) / ((pow(x3, 2) - pow(x2, 2)) * (x2 - x1) - (pow(x2, 2) - pow(x1, 2)) * (x3 - x2)); b = ((y2 - y1) - a * (pow(x2, 2) - pow(x1, 2))) / (x2 - x1); c = y1 - a * pow(x1, 2) - b * x1; s = a / 3 * (pow(x3, 3) - pow(x2, 3)) + (b - k) / 2 * (pow(x3, 2) - pow(x2, 2)) + (c - b1) * (x3 - x2); printf("%.2lf\n", s); } int main() { int n; char temp; scanf("%d", &n); scanf("%c", &temp); while(n--) { fMain(); } }
。。
相关文章推荐
- href链接传参乱码问题解决
- 颜色的几种不同的宏定义
- POJ 3342 Party at Hali-Bula (树形dp 树的最大独立集 判多解 好题)
- Asp.net MVC Request Life Cycle
- Atitit.异步编程 java .net php python js 对照
- Crontab定时任务配置
- [转]Failed to run the WC DB work queue associated with 错误的解决
- c语言,指针与数组--指针与二维数组2
- ie浏览器前缀特殊符号的识别
- 关于ueditor在javaweb项目中的集成
- hdu 5294 Tricks Device(2015多校第一场第7题)最大流+最短路
- 再谈c的内存管理及指针问题
- ArcGIS教程:编辑特征
- ADO.NET数据库访问技术
- poj 2299 Ultra-QuickSort 二分+线段树求逆序数
- 快速理解Docker - 容器级虚拟化解决方案
- 杭电5285二分图染色和并查集
- C++ I/O库流状态标志位
- 矩形面积并 POJ Atlantis
- 杭电OJ-1036_Average is not Fast Enough!