ZOJ 3645 BiliBili(高斯消元)
Shirai Kuroko is a Senior One student. Almost everyone in Academy City have super powers, and Kuroko is good at using it. Her ability is "Teleporting", which can make people to transfer in the eleven dimension, and it shows like moving instantly in general people's eyes.

In fact, the theory of the ability is simple. Each time, Kuroko will calculate the distance between some known objects and the destination in the eleven dimension so that Kuroko can get the coordinate of the destination where she want to go and use her ability.
Now we have known that the coordinate of twelve objects in the eleven dimension Vi = (Xi1,Xi2, ... ,Xi11), and 1 <= i <= 12. We also known that the distance Di between the destination and the object. Please write a program to calculate the coordinate of the destination. We can assume that the answer is unique and any four of the twelve objects are not on the same planar.
Input
The first line contains an integer T, means there are T test cases. For each test case, there are twelve lines, each line contains twelve real numbers, which means Xi1,Xi2, ... ,Xi11and Di. T is less than 100.
Output
For each test case, you need to output eleven real numbers, which shows the coordinate of the destination. Round to 2 decimal places.
题目大意:11维度上有一个未知的点,现在已知12个点的坐标和他们到这个未知的点的距离,求这个未知的点的坐标。
思路:设未知的点为(p1, p2, ……, pn)
那么对于每个已知点,列方程(xi1 - p1)^2 + (xi2 - p2)^2 + …… + (xin - pn)^2 = Di^2
然后,对于前11个方程,减去第12个方程,就能得到一个线性方程组。
然后高斯消元解即可。
PS:我的代码不加那个EPS会跪,我觉得以后没事还是把它加上吧……
代码(0MS):
- #include <cstdio>
- #include <iostream>
- #include <algorithm>
- #include <cstring>
- #include <cmath>
- using namespace std;
- const double EPS = 1e-;
- const int MAXN = ;
- double mat[MAXN][MAXN];
- int n = , T;
- inline int sgn(double x) {
- return (x > EPS) - (x < -EPS);
- }
- void guess_eliminatioin() {
- for(int i = ; i < n; ++i) {
- int r = i;
- for(int j = i + ; j < n; ++j)
- if(fabs(mat[j][i]) > fabs(mat[r][i])) r = j;
- if(sgn(mat[r][i]) == ) continue;
- if(r != i) for(int j = ; j <= n; ++j) swap(mat[r][j], mat[i][j]);
- for(int j = n; j >= i; --j)
- for(int k = i + ; k < n; ++k) mat[k][j] -= mat[k][i] / mat[i][i] * mat[i][j];
- }
- for(int i = n - ; i >= ; --i) {
- for(int j = i + ; j < n; ++j)
- mat[i][n] -= mat[j][n] * mat[i][j];
- mat[i][n] /= mat[i][i];
- }
- }
- int main() {
- scanf("%d", &T);
- while(T--) {
- for(int i = ; i <= n; ++i)
- for(int j = ; j <= n; ++j) scanf("%lf", &mat[i][j]);
- for(int i = ; i < n; ++i) {
- mat[i][n] = mat[i][n] * mat[i][n] - mat[n][n] * mat[n][n];
- for(int j = ; j < n; ++j) {
- mat[i][n] -= mat[i][j] * mat[i][j] - mat[n][j] * mat[n][j];
- mat[i][j] = - * mat[i][j] + * mat[n][j];
- }
- }
- guess_eliminatioin();
- for(int i = ; i < n - ; ++i) printf("%.2f ", mat[i][n] + EPS);
- printf("%.2f\n", mat[n - ][n] + EPS);
- }
- }
ZOJ 3645 BiliBili(高斯消元)的更多相关文章
- ZOJ 3645 BiliBili 高斯消元 难度:1
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4835 由题意,有: (x1-x11)^2 + (x2-x12)^2 ... = ...
- 「ZOJ 1354」Extended Lights Out「高斯消元」
题意:给定一个\(5\times 6\)的棋盘的\(01\)状态,每次操作可以使它自己和周围四个格子状态取反,求如何操作,输出一个\(01\)矩阵 题解:这题可以通过枚举第一行的状态然后剩下递推来做, ...
- 【BZOJ-3143】游走 高斯消元 + 概率期望
3143: [Hnoi2013]游走 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2264 Solved: 987[Submit][Status] ...
- 【BZOJ-3270】博物馆 高斯消元 + 概率期望
3270: 博物馆 Time Limit: 30 Sec Memory Limit: 128 MBSubmit: 292 Solved: 158[Submit][Status][Discuss] ...
- *POJ 1222 高斯消元
EXTENDED LIGHTS OUT Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9612 Accepted: 62 ...
- [bzoj1013][JSOI2008][球形空间产生器sphere] (高斯消元)
Description 有一个球形空间产生器能够在n维空间中产生一个坚硬的球体.现在,你被困在了这个n维球体中,你只知道球 面上n+1个点的坐标,你需要以最快的速度确定这个n维球体的球心坐标,以便于摧 ...
- hihoCoder 1196 高斯消元·二
Description 一个黑白网格,点一次会改变这个以及与其连通的其他方格的颜色,求最少点击次数使得所有全部变成黑色. Sol 高斯消元解异或方程组. 先建立一个方程组. \(x_i\) 表示这个点 ...
- BZOJ 2844 albus就是要第一个出场 ——高斯消元 线性基
[题目分析] 高斯消元求线性基. 题目本身不难,但是两种维护线性基的方法引起了我的思考. void gauss(){ k=n; F(i,1,n){ F(j,i+1,n) if (a[j]>a[i ...
- SPOJ HIGH Highways ——Matrix-Tree定理 高斯消元
[题目分析] Matrix-Tree定理+高斯消元 求矩阵行列式的值,就可以得到生成树的个数. 至于证明,可以去看Vflea King(炸树狂魔)的博客 [代码] #include <cmath ...
随机推荐
- fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
给对话框添加类, 报错 CalibrateMFCDlg.h(6) : error C2504: “CDialog”: 未定义基类 等多个错误 加上 #include "afxwin.h&qu ...
- 常见的Mule Esb下载地址
http://www.myexception.cn/open-source/1832157.html
- 【转】Servlet与web.xml的配置
Web.xml常用元素<web-app><display-name></display-name>定义了WEB应用的名字<description>< ...
- Qt 自定义 滚动条 样式(模仿QQ)
今天是时候把软件中的进度条给美化美化了,最初的想法就是仿照QQ. 先前的进度条是这样,默认的总是很难受欢迎的:美化之后的是这样,怎么样?稍微好看一点点了吧,最后告诉你实现这个简单的效果在Qt只需要加几 ...
- NOIP2013,复赛及同步赛,报名及比赛,专题页面
本通知的对象仅仅是福州第十九中学的学生 所有参加复赛以及同步赛的选手,请务必要仔细阅读:<关于CCF NOIP2013复赛有关事宜的通知>,里面有比赛的时间.地点.以及比赛费用的说明. 参 ...
- Cocos2d-JS替换初始化场景
Cocos2d-js工程默认启动入口为app.js,准备修改为另外一个入口文件如:GameScene.js var GameLayer = cc.Layer.extend({ ctor:functio ...
- Selenium2学习-008-WebUI自动化实战实例-006-易迅登录之 frame 处理
此文主要讲述用 Java 编写 Selenium 自动化测试脚本编写过程中,在因 frame 标签导致页面定位失败,提示 NoSuchElementException 时的,页面元素定位前的 fram ...
- 多大开始玩EV3
机器人EV3还是初中生才能玩的溜 耐撕爸爸推荐年龄:初中及以上 推荐理由:无需使用计算机就可进行编程,培养孩子的编程.机械.电子.物理等综合能力. 在欧美等国家,乐高机器人融入教学已成为一种普遍现象, ...
- [BS-15] Values of type 'NSInteger' should not be used as format arguments
Values of type 'NSInteger' should not be used as format arguments 苹果app支持arm64以后会有一个问题:NSInteger变成64 ...
- 11月23日《奥威Power-BI报表集成到其他系统》腾讯课堂开课啦
听说明天全国各地区都要冷到爆了,要是天气冷到可以放假就好了.想象一下大冷天的一定要在被窝里度过才对嘛,索性明天晚上来个相约吧,相约在被窝里看奥威Power-BI公开课如何? 上周奥威公开 ...