Magic Triangle | ||
Accepted : 82 | Submit : 186 | |
Time Limit : 1000 MS | Memory Limit : 65536 KB |
Magic TriangleProblem Description:Huangriq is a respectful acmer in ACM team of XTU because he brought the best place in regional contest in history of XTU. Huangriq works in a big company in Guangzhou now, all things goes well but the mosquitos are too disturbing. Mosquito net and mosquito-repellent incense are useless for this mosquito city. And finally he decides to use magic to kill them. He make a magic regular triangle as the picture shows. While the most proper position to launch magic is not always the center of circle. In order to make everything smoothly, Huangriq needs to get the value of . And he already get two of them, can you help him to figure out the rest one? InputThe first line contains a integer T(no more than 10000), which indicates the number of test cases. In the following T lines, each line contains two integers a and b () indicating the two angle Huangriq has already got. OutputFor each test case, output the rest angle's value with two digits after a decimal point in one line. Sample Input1 Sample Output30.00 SourceXTU OnlineJudge |
<span style="font-size:18px;">#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
#define ll long long
#define CL(a,b) memset(a,b,sizeof(a))
#define lson (i<<1)
#define rson ((i<<1)|1)
#define MAXN 100010
struct Point
{
double x,y;
};
Point A,B,C,O;
double Line(Point A, Point B)
{
return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}
double sub(Point A, Point B)
{
return A.x*B.x+A.y*B.y;
}
int main()
{
int T,a,b;
cin>>T;
while(T--)
{
cin>>a>>b;
A.x = 1, A.y = sqrt(3.0);
B.x = 0, B.y = 0;
C.x = 2, C.y = 0;
double k1,k2,b1,b2;///k1是BO的斜率,k2是CO的斜率
k1 = tan((60-a)*pi/180);
k2 = tan((180-b)*pi/180);
b1 = 0.0;
b2 = -2*k2;
O.x = (b2-b1)/(k1-k2);
O.y = k1*O.x + b1;
double AC = 2;
double AO = Line(A, O);
Point t1,t2;///t1表示向量AO,t2表示向量AC
t1.x = O.x - A.x; t1.y = O.y - A.y;
t2.x = C.x - A.x; t2.y = C.y - A.y;
double r = sub(t1, t2)/(AO*AC);
double ans = acos(r)*180/pi;
printf("%.2lf\n",ans);
}
return 0;
}
</span>