zoukankan      html  css  js  c++  java
  • HDU1071_数学几何

    题目大意: 给你三个点p1,p2,p3,p1是最高点,然后算出面积。 解题思路: 我的解题思路有点水,就是直接求抛物线系数,直线系数,最后求积分搞定e.尽量少用中间变量吧。代码有点丑。虽然这道题目是1a,但是还是有点儿毛毛的,就是怕三个点重合在一起,但是好像没有这种情况,测试数据应该还是比较弱吧。哈哈~ 自言自语: 一开始都懒得去用笔化简,但是画出来的时候,真爽,复杂的计算过程都由计算机包了,不过就是怕把公式敲到程序上,不小心就错了。额,刚刚出现了一个这样的问题,所以,做这种题,宁可慢慢来,一定要细心。 代码:
    #include
    #include
    using namespace std;
    
    int main(void)
    {
    	int n;
    	double x1, x2, x3, y1, y2, y3;
    	scanf("%d", &n);
    	for(int i = 0; i < n; i++)
    	{
    		scanf("%lf%lf", &x1, &y1);
    		scanf("%lf%lf", &x2, &y2);
    		scanf("%lf%lf", &x3, &y3);
    
    		double a, b, c, k, b1;
    		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;
    		k = (y3-y2) / (x3-x2);
    		b1 = y3 - k*x3;
    
    		//计算面积
    		double s;
    		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);
    	}
    	return 0;
    }
    
    
    
  • 相关阅读:
    chartjs 初步
    QT “error: error writing to -: Invalid argument”
    OTL mySQL
    qtcteater pro 文件配置
    Python os.readlink() 方法
    Python os.read() 方法
    Python os.popen() 方法
    Python os.pipe() 方法
    Python os.pathconf() 方法
    ThinkPHP框架前后台的分页调用
  • 原文地址:https://www.cnblogs.com/cchun/p/2520218.html
Copyright © 2011-2022 走看看