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) (水 ...
随机推荐
- Redis_Jedis使用总结
目录:1.pipeline2.跨jvm的id生成器3.跨jvm的锁实现(watch multi)4.redis分布式 1. Pipeline 官方的说明是:starts a pipeline,whic ...
- nodejs获取当前url和url参数值
//需要使用的模块 http url 当前url http://localhost:8888/select?aa=001&bb=002 var http = require('http ...
- MRP运算生成采购单时间的逻辑
由MRP运算产生的采购单日期,由生产单指定的安排计划日期.公司设置里的采购提前期和隐藏的供应商供货提前期三个字段共同决定. 可以很容易的在系统中找到,供应商供货提前期,需要在产品视图中将字段selle ...
- nfs基本配置
一.安装nfs: yum install nfs-utils rpcbind 创建共享目录:mkdir -p /XXX/export/ 修改配置文件:vim /etc/exports /XXX/exp ...
- DOS中cmd里常见的命令
我们使用计算机接触最频繁的就是DOS.DOS是英文Disk Operating System的缩写,意思是“磁盘操作系统”,顾名思义,DOS主要是一种面向磁盘的系统软件,说得简单些,DOS就是人给机器 ...
- UIDynamic(物理仿真)
简介 什么是UIDynamic UIDynamic是从iOS 7开始引入的一种新技术,隶属于UIKit框架 可以认为是一种物理引擎,能模拟和仿真现实生活中的物理现象 如: 重力.弹性碰撞等现象 物理引 ...
- 【HDU4578 Transformation】线段树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 题意:有一个序列,有四种操作: 1:区间[l,r]内的数全部加c. 2:区间[l,r]内的数全部 ...
- 房间安排-nyoj168
描述 2010年上海世界博览会(Expo2010),是第41届世界博览会.于2010年5月1日至10月31日期间,在中国上海市举行.本次世博会也是由中国举办的首届世界博览会.上海世博会以“城市,让生活 ...
- 为Eclipse安装主题插件
方法2:通过站点更新 eclipse:Help->Install New Software->Work with:Update Site -http://eclipse-color-the ...
- python子类调用父类的方法
python子类调用父类的方法 python和其他面向对象语言类似,每个类可以拥有一个或者多个父类,它们从父类那里继承了属性和方法.如果一个方法在子类的实例中被调用,或者一个属性在子类的实例中被访问, ...