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) (水 ...
随机推荐
- Android --ToggleButton的使用
1. 效果图
- BZOJ2453维护队列&&BZOJ2120数颜色
2016-05-28 11:20:22 共同的思路: 维护某种颜色上一次在哪里出现pre,可以知道当pre<询问的l时更新答案 块内按照pre排序 修改的时候重新O(n)扫一遍,如果和之前的不一 ...
- HDU 1520 树形dp裸题
1.HDU 1520 Anniversary party 2.总结:第一道树形dp,有点纠结 题意:公司聚会,员工与直接上司不能同时来,求最大权值和 #include<iostream> ...
- 转自大楚网:微软SAPI:让你的软件能说会道
[IT168专稿]“没声音,再好的戏也出不来.”这虽然是一句广告,但是也说出了一个道理,我们所开发的软件,特别是一些多媒体软件,要是能够发 出声音,能说会道,将为我们的软件增添不少光彩.同时,我们面临 ...
- Linux查看操作系统时间
date命令的功能是显示和设置系统日期和时间. 该命令的一般格式为: date [选项] 显示时间格式(以+开头,后面接格式) date 设置时间格式 命令中各选项的含义分别为: -d datestr ...
- webdriver中PDF控件无法显示的问题(IE兼容性)
公司的的系统只能运行在32位的IE上,开始从http://selenium-release.storage.googleapis.com/index.html?path=2.48/ 这个路径下去下载了 ...
- android-数据存储之远程服务器存储
一.如何编码实现客户端与服务器端的交互 <一>JDK内置原生API HttpUrlConnection <二>Android内置的包装API HttpClient浏览器 < ...
- sbt Getting org.scala-sbt sbt 0.13.12 ...
本地仓库被我搞乱了,一气之下整个删掉了本地仓库,再重启sbt卡在Getting这一步. Getting org.scala-sbt sbt 0.13.12 ... 卡住 补充sbt配置文件: 文件结构 ...
- 状态压缩 DP
D - Hie with the Pie Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:65536 ...
- Webform——中国省市三级联动以及IsPostBack
首先要明白Webform的运行顺序,当开始启动时候,首先执行的是Page_Load事件, 当点击任意按钮后,每次点击都要先执行一遍Page_Load(在这里Page_Load里面的事件是给数据控件加载 ...