UVA - 12301-An Angular Puzzle

给出如图三角形里的五个角度,求出x

我的做法:

直接写出表达式解

我的代码:

#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const double pi=acos(-1.0);
struct dot
{
	double x,y;
	dot(){}
	dot(double a,double b){x=a,y=b;}
	friend dot operator -(dot a,dot b){return dot(a.x-b.x,a.y-b.y);}
	friend double operator /(dot a,dot b){return a.x*b.x+a.y*b.y;}
};
double dis(dot a,dot b)
{
	return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
double cang(dot a,dot b)
{
	return acos(a/b/dis(a,dot(0,0))/dis(b,dot(0,0)));
}
double cg1(double a)
{
	return a/pi*180;
}
double cg2(double a)
{
	return a/180*pi;
}
int main()
{
	dot f,g;
	double a,b,c,d,e,k[10],ans;
	while(cin>>a>>b>>c>>d>>e)
	{
		if(a+b+c+d+e==0)
			break;
		if(a+b+c+d+e>180.0)
			printf("Impossible\n");
		else
		{
			a=cg2(a);b=cg2(b);c=cg2(c);d=cg2(d);e=cg2(e);
			k[1]=-tan(d+e);
			k[2]=tan(c);
			k[3]=tan(b+c);
			k[4]=-tan(e);
			f.x=k[1]/(k[1]-k[2]);
			f.y=k[2]*f.x;
			g.x=k[4]/(k[4]-k[3]);
			g.y=k[3]*g.x;
			ans=cg1(cang(f-g,f));
			printf("%.2lf\n",ans);
		}
	}
}
时间: 2024-12-11 16:42:18

UVA - 12301-An Angular Puzzle的相关文章

UVA - 12301 - An Angular Puzzle (计算几何~平面三角)

题目地址:点这里 思路:可以先确定A,B的坐标,然后再通过确定向量来硬算出角度..好像可以推公式做,没推出来╮(╯_╰)╭ AC代码: #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <cmath> using namespace std; const double PI = 4 * atan(1.0); struct P

UVA 12301 - An Angular Puzzle(计算几何)

这题就设AB是1,然后正弦余弦定理去搞搞搞就可以了 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const double PI = acos(-1.0); int a, b, c, d, e; double get(double x) { return x / 180.0 * PI; } int main

UVa 227 / UVALive 5166 Puzzle 谜题 (结构体)

Puzzle Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Description   A children's puzzle that was popular 30 years ago consisted of a 5x5 frame which contained 24 small squares of equal size. A unique letter of the alphabet

uva 1399 - Puzzle(AC自动机)

题目链接:uva 1399 - Puzzle 题目大意:给定K和N,表示有K种不同的字符,N个禁止串,求一个最长的串使得该串不包含任何禁止串为子串.如果存在循环或者不能构成的话,输出No. 解题思路:建立AC自动机,然后在AC自动机上做dp,所有单词结尾节点为禁止点. #include <cstdio> #include <cstring> #include <queue> #include <algorithm> using namespace std;

UVA 1399 - Puzzle(AC自动机+DP)

UVA 1399 - Puzzle 题目链接 题意:给定一些字符串,求一个最长的不在包含这些子串的字符串,如果可以无限长输出No 思路:建ACM自动机,把不可走结点标记构造出来,然后在这个状态图上进行dp找出最长路径即可,至于无限长的情况,只要在dp前进行一次dfs判有没有环即可 代码: #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include &

UVa - 227 - Puzzle

给空格子上下左右的互换操作,问最后是怎样的 注意一行的最后一个若是空格,需要自己加注意读取时 操作可能分好多行,一定要读取到 0 为止 1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 char map[50][50],op[1000],c,tmp; 5 int k,t,x,y,cnt; 6 bool flag; 7 void fuc() 8 { 9 flag=1; 10 for(int i=0;

uva live 12846 A Daisy Puzzle Game

如果下一个状态有必败,那么此时状态一定是必胜,否则此时状态一定是必败 状压DP #include<iostream> #include<map> #include<string> #include<cstring> #include<cstdio> #include<cstdlib> #include<cmath> #include<queue> #include<vector> #include&

UVA 227 Puzzle - 输入输出

题目: acm.hust.edu.cn/vjudge/roblem/viewProblem.action?id=19191 这道题本身难度不大,但输入输出时需要特别小心,一不留神就会出问题. 对于输入,如果要读入一行时: 没有空白字符,则直接使用scanf和%s即可: 有空白字符,使用gets,但要小心溢出:fgets一直不能正常工作,有待研究(gets会将缓冲区多余的\n扔掉,fgets会保留在字符串中): 对于要读入单个字符时: 使用scanf和“ %c”进行舍弃空白字符(注意空格),并且最

Puzzle UVA - 227

A children's puzzle that was popular 30 years ago consisted of a 5×5 frame which contained 24 small squares of equal size. A unique letter of the alphabet was printed on each small square. Since there were only 24 squares within the frame, the frame