poj 3129 How I Wonder What You Are! 点积求两向量夹角

水题,直接贴代码。

//poj 3129
//sep9
#include <iostream>
#include <cmath>
using namespace std;
const double eps=0.00000001;
struct P{
	double x,y,z;
}p[512],tel[64];
double a[64];
int main()
{
	int i,j,cnt,n,m;
	while(scanf("%d",&n)==1&&n){
		cnt=0;
		for(i=0;i<n;++i)
			scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z);
		scanf("%d",&m);
		for(i=0;i<m;++i)
			scanf("%lf%lf%lf%lf",&tel[i].x,&tel[i].y,&tel[i].z,&a[i]);
		for(i=0;i<n;++i){
			int ok=0;
			for(j=0;j<m&&!ok;++j){
				double ra=sqrt(p[i].x*p[i].x+p[i].y*p[i].y+p[i].z*p[i].z);
				double rb=sqrt(tel[j].x*tel[j].x+tel[j].y*tel[j].y+tel[j].z*tel[j].z);
				double c=acos((p[i].x*tel[j].x+p[i].y*tel[j].y+p[i].z*tel[j].z)/(ra*rb));
				if(c<a[j]||fabs(c-a[j])<eps)
					ok=1;
			}
			if(ok)
				++cnt;
		}
		printf("%d\n",cnt);
	}
	return 0;
}
时间: 2024-10-19 15:00:57

poj 3129 How I Wonder What You Are! 点积求两向量夹角的相关文章

POJ 2546 &amp; ZOJ 1597 Circular Area(求两圆相交的面积 模板)

题目链接: POJ:http://poj.org/problem?id=2546 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=597 Description Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three di

poj 2763 树链剖分(单点更新,区间求值)

http://poj.org/problem?id=2763 Description After their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. People in XX Village lived in beautiful huts. There are some pairs of huts connected by bidirectional ro

POJ 1515 Street Directions --一道连通题的双连通和强连通两种解法

题意:将一个无向图中的双向边改成单向边使图强连通,问最多能改多少条边,输出改造后的图. 分析: 1.双连通做法: 双连通图转强连通图的算法:对双连通图进行dfs,在搜索的过程中就能按照搜索的方向给所有边定向,其中桥不能改造,只能保留双向边. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #includ

POJ 1753 Flip Game (高斯消元 枚举自由变元求最小步数)

题目链接 题意:4*4的黑白棋,求把棋全变白或者全变黑的最小步数. 分析:以前用状态压缩做过. 和上题差不多,唯一的不同是这个终态是黑棋或者白棋, 但是只需要把给的初态做不同的两次处理就行了. 感觉现在还只是会套模板,不能独立的思考,好伤心.... 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <cmath&g

POJ 1080 Human Gene Functions(求两字符串相似度:LCS变形)

POJ 1080 Human Gene Functions(求两字符串相似度:LCS变形) http://poj.org/problem?id=1080 题意: HDU1080 给你两个由字符A,C,G,T构造的字符串s1和s2, 现在你可以在这两个字符串中插入空格, 使得两串长相等(但是不能使得s1的空格对应s2的空格位置). 然后给你s1的特定字符对应s2中特定字符所能获得的分数矩阵: 问你最后两个字符串所能获得的最大分数是多少? 分析: 本题很类似于求字符串最短编辑距离或者求字符串LCS的

POJ 2774 Long Long Message &amp;&amp; URAL 1517. Freedom of Choice(求最长重复子序列)

两个题目意思差不多,都是让求最长公共子串,只不过poj那个让输出长度,而URAL那个让输出一个任意的最长的子串. 解体思路: Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 22313   Accepted: 9145 Case Time Limit: 1000MS Description The little cat is majoring in physics in the cap

POJ 3928 &amp; HDU 2492 Ping pong(树状数组求逆序数)

题目链接: PKU:http://poj.org/problem?id=3928 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2492 Description N(3<=N<=20000) ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To im

POJ 题目3415 Common Substrings(后缀数组+栈,求可以匹配到的长度大于k的公共子串个数)

Common Substrings Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 8471   Accepted: 2798 Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two strings A, B and one integer K, we define S, a

UVALive 4639 &amp;&amp; SPOJ SPOINTS &amp;&amp; POJ 3805 &amp;&amp; AOJ 1298 Separate Points 求两个凸包是否相交 难度:3

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2640 http://www.spoj.com/problems/SPOINTS/en/ http://poj.org/problem?id=3805 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1298 要