码迷,mamicode.com
首页 > 编程语言 > 详细

HDOJ-ACM1071(JAVA) 定积分

时间:2016-06-20 00:33:11      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

这道题做起来有点无奈,定积分已经忘得差不多了~还可恶的去搜索了抛物线的解析式的求法~哈哈

不过求出来的结果不对...等有时间再去研究这个数学问题吧 - -

以下是JAVA实现:

import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int n = scan.nextInt();
        while(n--!=0){
            double x1 = scan.nextDouble();
            double y1 = scan.nextDouble();
            double x2 = scan.nextDouble();
            double y2 = scan.nextDouble();
            double x3 = scan.nextDouble();
            double y3 = scan.nextDouble();
            double a = ((y2-y1)*(x3-x2)/(x2-x1)-(y3-y2))/((x2*x2-x1*x1)*(x3-x2)/(x2-x1)-(x3*x3-x2*x2));
            double b = ((y2-y1)-a*(x2*x2-x1*x1))/(x2-x1);
            double c = y1-a*x1*x1-b*x1;
            double s = (a/3*x3*x3*x3+b/2*x3*x3+c*x3)-(a/3*x2*x2*x2+b*x2*x2/2+c*x2)-(y3+y2)*(x3-x2)/2;
            System.out.printf("%.2f",s);
            System.out.println();
        }
        scan.close();
    }

}

 

HDOJ-ACM1071(JAVA) 定积分

标签:

原文地址:http://www.cnblogs.com/xiezie/p/5599094.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!