`

1071 : The area

c 
阅读更多


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5805    Accepted Submission(s): 4051

题目附加图片



/* 
    Name: 
    Copyright: 
    Author: skywolf 
    Date: 06-04-13 22:36 
    Description: 本文为原创,转载请注明出处。 
*/ 

#include <stdio.h>

double calculate(double x);

int T;
double x1, x2, x3, y1, y2, y3;
double k1, b, a;

int main() {

	while(scanf("%d", &T) != EOF) {
		while(T--) {
			scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
			//求直线的斜率: k1
			k1 = (y3 - y2) / (x3 - x2);
			//直线的方程 : y = k1*x + b; 
			b = y2 - k1 * x2;  
			// 抛物线的方程 : y = a(x - x1)^2 + y1;
			a = (y2 - y1) / (x2 - x1) / (x2 - x1);
			printf("%.2lf\n", calculate(x3)-calculate(x2));
		} 
	}
	return 0;
}

double calculate(double x) {
	
	return a/3*x*x*x - (a*x1+k1/2)*x*x + (a*x1*x1+y1-b)*x;
} 




题目连接
  • 大小: 1.4 KB
0
4
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics