题目链接:点击打开链接
这个题目其实也想了好多的方法,直接求公式求不出来,二分啥的,想了一遍,列的那个式子,后来还要判断单调性啥的,想想的话,应该可以实现的,但是我还没有做,另外看了别人发的解法,其实也没有看怎么懂,只是发个解法,然后高大上得公式,然后就看不懂了,就不会做了,人家说要用向量,我当时也是想不到怎么使用向量,后来是看了别人·的题解,才知道是怎么做的了,其实这个过程也不是特别的复杂,但是就是想不起来,还看到别人说了这样的一句话,这种角度的题目不要往角度上想,因为那只是一个误区,其实我的数学不是怎么好,先看一下代码:
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
#include<iostream>
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;
O.y=k2*(O.x-2);
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;
}
这个代码就是别人的,我感觉也没有什么好改的了,因为这就是这个样子,有了计算的原理,就可以实现了,还是学的太少。