zoukankan      html  css  js  c++  java
  • 杭电acm the area

    这题直接使用积分的方法来做,不需要考虑交叉点和顶点重合的情况:

    不能使用float作为变量,否则一直wa

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main(){
    	int t;
    	scanf("%d",&t);
    	while(t--){
    	double x1,y1,x2,y2,x3,y3;
    	  cin>>x1>>y1>>x2>>y2>>x3>>y3;
    	  double k = (y3-y2)/(x3-x2);
    	  double m = y2-k*x2;
    	  double k1=(y2-y1)/((x2-x1)*(x2-x1));
    	  double a = k1;
    	  double b = -2*a*x1;
    	  double c = a*x1*x1+y1;
    	  double s =
    				a/3*(x3*x3*x3-x2*x2*x2)+
    				0.5*(b-k)*(x3*x3-x2*x2)+(c-m)*(x3-x2);
    		printf("%.2f
    ",s);
    	}
    }
    
  • 相关阅读:
    世纪末的星期
    马虎的算式
    蜜蜂飞舞
    Torry 的困惑
    级数调和
    数列
    最大最小公倍数
    蚂蚁感冒
    12.integer to Roman
    13.Roman to Integer
  • 原文地址:https://www.cnblogs.com/jackwuyongxing/p/4539426.html
Copyright © 2011-2022 走看看