zjuoj 3608 Signal Detection
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3608
Signal Detection
Time Limit: 2 Seconds Memory Limit: 65536 KB
| Parallelepiped | |
|---|---|
![]() |
|
| Type | Prism |
| Faces | 6 parallelograms |
| Edges | 12 |
| Vertices | 8 |
Dr. Gale is testing his laser system. He uses a detector to collect the signals from a laser generator. He also puts a special prism in the system so that he can filter the noise. But he is not very sure where to put the detector to collect the signals. Can you help him with this problem?


In order to simplify the problem, here we assume the prism is a parallelepiped, which is a three-dimensional figure formed by six parallelograms. The laser goes in one direction and the detector can receive signals from any direction. The detector is placed on the ground where the z-coordinate is zero. There is no energy lost in the refraction. That is to say, there is no reflection in the signal transmission. You don't need to consider the situation of total reflection or the degenerate situation.
Input
There are multiple test cases. The first line of input contains an integer T (T ≤ 50) indicating the number of test cases. Then T test cases follow.
The first line of each test case contains 3 integers, indicating the coordinates of the laser generator. The second line contains 3 integers describing a point the laser will go through without the prism. The third line contains 3 integers describing a vertex A of the prism. The fourth to the sixth lines contain 3 integers each, describing an adjacent vertex of A. The seventh line contains a real number u, the refractive index of the prism.(1 < u ≤ 10) The absolute value of the coordinates will not exceed 1000. The z coordinates are all nonnegative. The prism and the laser generator are strictly above the ground and the laser generator will not be inside the prism.
Output
If there is no place in the ground that can receive the signals output "Error". Otherwise, output the x and y coordinates the place accurate to 0.001.
Sample Input
2
0 0 10
0 0 0
-5 -5 1
5 -5 11
-5 5 1
-6 -5 2
1.4142136
0 0 10
0 0 11
-5 -5 1
5 -5 1
-5 5 1
-5 -5 2
2
Sample Output
0.423 0.000
Error
References
Author: GUAN, Yao
Contest: The 9th Zhejiang Provincial Collegiate Programming Contest
AC代码:
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <time.h>
using namespace std;
typedef long long llong; inline int bit(int x, int i){ return (x>>i) & ;}
inline int setb(int x, int i){ return x | ( << i);}
inline int clrb(int x, int i){ return x & (~( << i));}
inline int lowb(int x){return x & (-x);}
const double eps = 1e-;
struct Point{
double x, y, z;
Point(){}
Point(double x, double y, double z):x(x), y(y), z(z){}
double len(){
return sqrt(x * x + y * y + z * z);
}
Point shrink(double l = 1.0){
double s = l / len();
return Point(x * s, y * s, z * s);
}
void input(){
scanf("%lf %lf %lf", &x, &y, &z);
}
}; Point operator +(const Point &p, const Point &q){
return Point(p.x + q.x, p.y + q.y, p.z + q.z);
}
Point operator -(const Point &p, const Point &q){
return Point(p.x - q.x, p.y - q.y, p.z - q.z);
}
Point operator *(const Point &p, const double &s){
return Point(p.x * s, p.y * s, p.z * s);
}
Point operator *(const Point &p, const Point &q){
return Point(p.y * q.z - p.z * q.y,
p.z * q.x - p.x * q.z,
p.x * q.y - p.y * q.x);
}
double operator &(const Point &p, const Point &q){
return p.x * q.x + p.y * q.y + p.z * q.z;
} Point p, q, v[];
double r;
int face[][] ={
{, , , },
{, , , },
{, , , },
{, , , },
{, , , },
{, , , },
};
Point fn[];
double fb[]; double inter(const Point &p, const Point &d, const Point &n, double b){
return (b - (n & p)) / (n & d);
}
bool collide(double R){
int hf = -;
double ht;
Point d = (q - p);
for(int i = ;i < ; ++i){
if(fabs(fn[i] & d) < eps) continue;
double t = inter(p, d, fn[i], fb[i]);
if(t <= eps) continue;
Point hit = p + d * t;
bool ok = true;
for(int j = ;j < ; ++j){
if((((v[face[i][j]]-hit) * (v[face[i][(j + )%]] - hit)) & fn[i]) <= ) ok = false;
}
if(ok && (hf < || t < ht)){
hf = i;
ht = t;
}
}
if(hf < ) return false; Point hit = p + d * ht;
Point vx = fn[hf].shrink();
if(fabs((vx * d).len()) < eps){
p = hit;
q = hit + d;
return true;
}
double dx = vx & d;
if(dx < ) vx = vx * -, dx = -dx;
Point vy = ((vx * d) * vx).shrink();
double dy = vy & d;
if(dy < ) vy = vy * -, dy = -dy;
double theta0 = atan2(dy, dx);
double theta = asin(sin(theta0) / R);
d = vx * cos(theta) + vy * sin(theta);
p = hit;
q = hit + d;
return true;
}
int main(){
int TT;
scanf("%d", &TT);
for(int cas = ; cas <= TT; ++cas){
p.input();
q.input(); v[].input();
v[].input();
v[].input();
v[] = v[] + v[] - v[]; v[].input();
v[] = v[] + v[] - v[];
v[] = v[] + v[] - v[];
v[] = v[] + v[] - v[]; scanf("%lf", &r);
for(int i = ;i < ; ++i){
fn[i] = (v[face[i][]] - v[face[i][]]) *
(v[face[i][]] - v[face[i][]]);
fb[i] = fn[i] & v[face[i][]];
}
if(collide(r)){
collide(./r);
}
Point norm(, , );
Point dir = q - p;
if(fabs(norm & dir) < eps) puts("Error");
else{
double t = inter(p, dir, norm, );
if(t < ) puts("Error");
else{
Point hit = p + dir * t;
printf("%.3f %.3f\n", hit.x, hit.y);
}
}
}
return ;
}
zjuoj 3608 Signal Detection的更多相关文章
- 第二届普适计算和信号处理及应用国际会议论文2016年 The 2nd Conference on Pervasive Computing, Signal Processing and Applications(PCSPA, 2016)
A New Method for Mutual Coupling Correction of Array Output Signal 一种阵列输出信号互耦校正的新方法 Research of Robu ...
- Image Processing and Analysis_8_Edge Detection:Statistical edge detection_ learning and evaluating edge cues——2003
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...
- libevent
libevent doc example #include <event2/event.h> void cb_func(evutil_socket_t fd, short what, vo ...
- ROC和AUC介绍以及如何计算AUC ---好!!!!
from:https://www.douban.com/note/284051363/?type=like 原帖发表在我的博客:http://alexkong.net/2013/06/introduc ...
- 【转】ROC和AUC介绍以及如何计算AUC
转自:https://www.douban.com/note/284051363/ ROC(Receiver Operating Characteristic)曲线和AUC常被用来评价一个二值分类器( ...
- 利用过采样技术提高ADC测量微弱信号时的分辨率
1. 引言 随着科学技术的发展,人们对宏观和微观世界逐步了解,越来越多领域(物理学.化学.天文学.军事雷达.地震学.生物医学等)的微弱信号需要被检测,例如:弱磁.弱光.微震动.小位移.心电.脑电等[1 ...
- DSP开发资源总结,经典书籍,论坛
OMAP4开发资源总结: 一.TI OMAP4官网介绍: http://www.ti.com.cn/general/cn/docs/wtbu/wtbuproductcontent.tsp?templa ...
- 分类器的评价指标-ROC&AUC
ROC 曲线:接收者操作特征曲线(receiver operating characteristic curve),是反映敏感性和特异性连续变量的综合指标,roc 曲线上每个点反映着对同一信号刺激的感 ...
- 2012-2014 三年浙江 acm 省赛 题目 分类
The 9th Zhejiang Provincial Collegiate Programming Contest A Taxi Fare 25.57% (166/649) (水 ...
随机推荐
- 集成IOS 环信SDK
集成IOS SDK 在您阅读此文档时,我们假定您已经具备了基础的 iOS 应用开发经验,并能够理解相关基础概念. 下载SDK 通过Cocoapods下载地址 不包含实时语音版本SDK(EaseMobC ...
- JAVA操作MongoDB数据库
1. 首先,下载MongoDB对Java支持的驱动包 驱动包下载地址:https://github.com/mongodb/mongo-java-driver/downloads 2.Java操作Mo ...
- sencha怎么在control层调用按钮
暂时在这里总结了3种方法: config: { refs: { sendMaint: 'sendMaint', basicinfolist:'basicinfolist',refreshButton: ...
- Music
Music 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88890#problem/C 题目: Description Lit ...
- #nav li:hover ul 与#nav li a:hover ul 的区别
#nav li:hover ul 与#nav li a:hover ul 有什么区别? ──────────────────────────────────────────── #nav li:hov ...
- iOS五种本地缓存数据方式
iOS五种本地缓存数据方式 iOS本地缓存数据方式有五种:前言 1.直接写文件方式:可以存储的对象有NSString.NSArray.NSDictionary.NSData.NSNumber,数据 ...
- 远程访问mysql
转载:http://www.codesky.net/article/201108/106005.html 数据库不允许从远程访问怎么办?本文提供了三种解决方法: 1.改表法.可能是你的帐号不允许从远程 ...
- Java web MVC开发模式入门感悟
当我进行第一个完整的java web项目的开发时,对以前所学的Java web知识体系有了一个清晰的进阶认识.我觉得非常有必要对此进行必要的总结. MVC,意指model(数据持久层)+viewer( ...
- hdu-acm steps 免费馅饼
/*dp入门级的题目,和数塔是一样的,这道题不用做什么优化,感觉时间复杂度不会超.主要还是细节上的问题, 这道题的状态和状态方程都容易找到,采用自底向上的方式会好很多*/ #include" ...
- Hibernate SQLQuery简单实用,做链接查询
工单里面可能有0个告警,一个或多个告警,当工单中没有告警的时候也需要将工单显示出来,所以就需要使用工单和告警的做链接查询,下面是具体实例 表: CREATE TABLE `alarm` ( `id` ...
