ACdream 1203 - KIDx's Triangle(解题报告)

KIDx‘s Triangle

Time Limit: 2000/1000MS (Java/Others)
Memory Limit: 128000/64000KB (Java/Others)

Submit
Statistic Next Problem

Problem Description

One day, KIDx solved a math problem for middle students in seconds! And than he created this problem.

Now, give you the degree of a, b, c, d, please calculate the degree of ∠AED.

Input

There are multiple test cases.

Each case contains one line 4 integers formatted as: "a b c d"

0 ≤ a, b, c, d < 90°.

0 < a+b < 90°, 0 < c+d < 90°.

Output

For each test case, output the answer in one line, rounded to
2 decimal places.

Sample Input

10 70 60 20
10 70 70 0

Sample Output

20.00
140.00

参考代码:

#include<stdio.h>
#include<math.h>
#define pi acos(-1.0)
int main()
{
	double a,b,c,d;
	double e;
	double AD,BD,BE,DE,AE;
	while(~scanf("%lf%lf%lf%lf",&a,&b,&c,&d))
	{
		a=a*1.0*pi/180;
		b=b*1.0*pi/180;
		c=c*1.0*pi/180;
		d=d*1.0*pi/180;
		if(a==0||c==0)
		{
			printf("0.00\n");
			continue;
		}
		AD=sin(c)/sin(a+b+c);
		BD=sin(c+d)/sin(a+b+c+d)-sin(c)/sin(a+b+c);
		BE=sin(a+b)/sin(a+b+c+d)-sin(b)/sin(b+c+d);
		DE=sqrt((BE*BE+BD*BD+2.0*BE*BD*cos(a+b+c+d)));
		AE=sin(c+d)/sin(b+c+d);
		e=acos(((1.0*DE*DE+AE*AE-AD*AD)/(2.0*DE*AE)))/pi*180;

		if(e<0)
		    printf("%.2f\n",180-e);
        else
            printf("%.2f\n",e);

	}
	return 0;
}

版权声明:本文为博主原创文章,随便转载。

ACdream 1203 - KIDx's Triangle(解题报告)

时间: 2024-10-24 23:36:06

ACdream 1203 - KIDx's Triangle(解题报告)的相关文章

Acdream 1203 KIDx&#39;s Triangle(解三角形)

题目链接:传送门 分析 给定角a,b,c,d.然后求角AED,这题其实就是高中的计算几何解三角形题目. 正弦定理: A/sin(A) = B/sin(B) = C/sin(C)=2*R (R为三角形外接圆的半径) 余弦定理:A^2 = B^2 + C^2 - 2*B*C*cos(A). 然后我们设AB = x ,然后可以通过正弦定理求出AD,BD,BE,AE,然后通过余弦定理 可以求出DE最后在通过正弦定理就可以求出角AED.需要注意的是asin()的范围为 [-pi/2,pi/2],我们得到的

数学 ACdream 1196 KIDx&#39;s Triangle

题目传送门 1 /* 2 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 3 注意:a==0时要特判:) 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <iostream> 8 #include <cstring> 9 #include <string> 10 #include <cmath> 11 using namespace std; 1

LeetCode: Pascal&#39;s Triangle 解题报告

Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] SOLUTION 1:很easy的题.注意记得把List加到ret中.比较简单,每一行的每一个元素有这个规律:1. 左右2边的是1.i, j 表示行,列坐标.2.

acdream.18.KIDx&#39;s Triangle(数学推导)

KIDx's Triangle Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description One day, KIDx solved a math problem for middle students in seconds! And than he created this problem. N

LeetCode: Triangle 解题报告

Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle[     [2],    [3,4],   [6,5,7],  [4,1,8,3]]The minimum path sum from top to

【LeetCode】Triangle 解题报告

[题目] Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bottom is 

LeetCode: Pascal&#39;s Triangle II 解题报告

Pascal's Triangle II Total Accepted: 19384 Total Submissions: 63446 My Submissions Question SolutionGiven an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us

Pascal&#39;s Triangle &amp; II 解题报告

杨辉三角,分别求前n行和第n行. [求杨辉三角前n行] Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 基础题,直接看代码,注意边界. public class Solution { public List<List<Integer>&g

leetCode解题报告5道题(八)

题目一: Populating Next Right Pointers in Each Node Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right node, the