UVALive 2145 Lost in Space(暴力)
题目并不难,就是暴力,需要注意一下输出形式和精度。
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define maxn 100
#define jd 0.0001
double x[maxn],y[maxn],z[maxn],d,e,f;
double getdis(double x,double y,double z,double x1,double y1,double z1)
{
return sqrt((x1-x)*(x1-x) + (y1-y)*(y1-y) + (z1-z)*(z1-z));
}
bool Judge(double a,double b,double c)
{
double ra1 = a/d;
double ra2 = b/e;
double ra3 = c/f;
if(fabs(ra1-ra2)<jd && fabs(ra1-ra3)<jd && fabs(ra2-ra3)<jd) return true;
return false;
}
int P,Q,R;
bool Solve(double ij,double jk,double ik,int i,int j,int k)
{
if(Judge(ij,jk,ik)) {P = k; Q = i; R = j; return true;}
if(Judge(ik,jk,ij)) {P = j; Q = i; R = k; return true;}
if(Judge(ij,ik,jk)) {P = k; Q = j; R = i; return true;}
if(Judge(jk,ik,ij)) {P = i; Q = j; R = k; return true;}
if(Judge(ik,ij,jk)) {P = j; Q = k; R = i; return true;}
if(Judge(jk,ij,ik)) {P = i; Q = k; R = j; return true;}
return false;
}
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf",&d,&e,&f);
scanf("%d",&n);
for(int i = ; i <= n; i++)
{
scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);
}
int ans,tmp;
for(int i = ; i <= n; i++)
{
for(int j = i+; j <= n; j++)
{
for(int k = j+; k <= n; k++)
{
double ij = getdis(x[i],y[i],z[i],x[j],y[j],z[j]);
double jk = getdis(x[j],y[j],z[j],x[k],y[k],z[k]);
double ik = getdis(x[i],y[i],z[i],x[k],y[k],z[k]);
if(Solve(ij,jk,ik,i,j,k) == true)
{
printf("%d %d %d\n",P,Q,R);
}
}
}
}
}
return ;
}
UVALive 2145 Lost in Space(暴力)的更多相关文章
- UVALive 7279 Sheldon Numbers (暴力打表)
Sheldon Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/H Description According t ...
- UVALive 7070 The E-pang Palace 暴力
The E-pang Palace Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/problem ...
- UVALive - 4026 Difficult Melody(暴力)
我这个英语学渣又把题给翻译错了……(话说,六级差十分没有过,好心疼T T),题目中说的P和Q都是计算game的个数,我以为是出现的次数,各种wa..后来调整了以后又是各种wa,原来是double型的数 ...
- UVALive - 6185 Find the Outlier暴力填表+高斯消元+卡eps
https://cn.vjudge.net/problem/UVALive-6185 我真的是服了orz eps 1e5,1e6过不了 开1e2 1e1都能过 题意:给你一个d阶多项式f的f(0),f ...
- UVaLive 7457 Discrete Logarithm Problem (暴力)
题意:求一个x使得 a^x%p = b p为素数: 析:从1开始扫一下就好,扫到p-1就可以了,关键是这个题为什么要用文件尾结束,明明说是0,但是不写就WA... 代码如下: #pragma comm ...
- UVaLive 6585 && Gym 100299F Draughts (暴力+回溯)
题意:给定一个 10*10的矩阵,每一个W可以跳过一个B向对角走到#并把B吃掉,并且可以一直跳直到不能动为止,现在是W走的时候,问你最多吃几个B. 析:直接暴力+回溯,深搜就好. 代码如下: #pra ...
- 290. Word Pattern 单词匹配模式
[抄题]: Given a pattern and a string str, find if str follows the same pattern. Here follow means a fu ...
- UVALive 4425 Another Brick in the Wall 暴力
C - Another Brick in the Wall Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & ...
- Gym 100299C && UVaLive 6582 Magical GCD (暴力+数论)
题意:给出一个长度在 100 000 以内的正整数序列,大小不超过 10^ 12.求一个连续子序列,使得在所有的连续子序列中, 它们的GCD值乘以它们的长度最大. 析:暴力枚举右端点,然后在枚举左端点 ...
随机推荐
- Java 散知识
1.final关键字的用法: 1. final关键字修饰一个基本类型的变量时,该变量不能重新赋值,第一次的值为最终的. 2. fianl关键字修饰一个引用类型变量时,该变量不能重新指向新的对象. 3. ...
- Openjudge-计算概论(A)-晶晶赴约会
描述 晶晶的朋友贝贝约晶晶下周一起去看展览,但晶晶每周的1.3.5有课必须上课,请帮晶晶判断她能否接受贝贝的邀请,如果能输出YES:如果不能则输出NO. 输入输入有一行,贝贝邀请晶晶去看展览的日期,用 ...
- android资源文件的选取
Android app项目中,res是用来存放资源文件的,来看看这些文件的创建和选取规则: 系统启动一个apk后,生成UI的过程中,会根据不同的系统配置来匹配.选择相应的资源文件. You shoul ...
- FbinstTool(U盘启动盘制作工具) v1.606 免费绿色版
软件名称: FbinstTool(U盘启动盘制作工具) v1.606 免费绿色版软件语言: 简体中文授权方式: 免费软件运行环境: Win7 / Vista / Win2003 / WinXP / W ...
- MVC view视图获取Html.RenderAction方式带来的参数
通过Html.RenderAction这种方式传递的参数,在view视图中获取要使用viewContext上下文来获取:Html.ViewContext.RouteData.Values[" ...
- Confluence搭建
参见 https://confluence.atlassian.com/display/CONF54/Installing+the+Confluence+EAR-WAR+Edition 下载5.4.4 ...
- asp 操作 json
<% Dim sc4Json Sub InitScriptControl Set sc4Json =Server.CreateObject("MSScriptControl.Scrip ...
- finally语句包含return的情况
结论:1.不管有木有出现异常,finally块中代码都会执行:2.当try和catch中有return时,finally仍然会执行:3.finally是在return后面的表达式运算后执行的(此时并没 ...
- 项目管理实践【六】自动同步数据库【Using Visual Studio with Source Control System to synchronize database automatically】
在上一篇项目管理实践[五]自动编译和发布网站中,我们讲解了如何使用MSBuild+Robocopy+WebDeployment来自动编译和部署网站,今天,我们来看一下,如何使用MSBuild +SVN ...
- RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
之前测试安装好Theano之后就去安装Tensorflow,然后再回来执行Theano的测试语句的时候,就出现以下错误了: google了一下,尝试了一下解决方法 import numpy print ...