题目链接:

https://www.lydsy.com/JudgeOnline/problem.php?id=1013

题目大意:

有一个球形空间产生器能够在n维空间中产生一个坚硬的球体。现在,你被困在了这个n维球体中,你只知道球面上n+1个点的坐标,你需要以最快的速度确定这个n维球体的球心坐标,以便于摧毁这个球形空间产生器。

思路:

每两个可以构成一个n个变量的式子,可以构造出n个不同的式子,进行高斯消元求解。

高斯消元模板:

 typedef double Matrix[maxn][maxn];
void gauss(Matrix A, int n)
{
for(int i = ; i < n; i++)
{
int r = i;
for(int j = i + ; j < n; j++)
if(fabs(A[j][i]) > fabs(A[r][i]))r = j;
if(r != i)for(int j = ; j <= n; j++)swap(A[r][j], A[i][j]);
for(int k = i + ; k < n; k++)
{
double f = A[k][i] / A[i][i];
for(int j = i; j <= n; j++)A[k][j] -= f * A[i][j];
}
} for(int i = n - ; i >= ; i--)
{
for(int j = i + ; j < n; j++)
{
A[i][n] -= A[j][n] * A[i][j];
}
A[i][n] /= A[i][i];
}
}
 #include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);//不可再使用scanf printf
#define Max(a, b) ((a) > (b) ? (a) : (b))//禁用于函数,会超时
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Mem(a) memset(a, 0, sizeof(a))
#define Dis(x, y, x1, y1) ((x - x1) * (x - x1) + (y - y1) * (y - y1))
#define MID(l, r) ((l) + ((r) - (l)) / 2)
#define lson ((o)<<1)
#define rson ((o)<<1|1)
#pragma comment(linker, "/STACK:102400000,102400000")//栈外挂
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} typedef long long ll;
const int maxn = + ;
const int mod = ;//const引用更快,宏定义也更快
const int INF = 1e9;
typedef double Matrix[maxn][maxn];
double a[maxn][maxn];
double tmp[maxn][maxn];
void gauss(Matrix A, int n)
{
for(int i = ; i < n; i++)
{
int r = i;
for(int j = i + ; j < n; j++)
if(fabs(A[j][i]) > fabs(A[r][i]))r = j;
if(r != i)for(int j = ; j <= n; j++)swap(A[r][j], A[i][j]);
for(int k = i + ; k < n; k++)
{
double f = A[k][i] / A[i][i];
for(int j = i; j <= n; j++)A[k][j] -= f * A[i][j];
}
} for(int i = n - ; i >= ; i--)
{
for(int j = i + ; j < n; j++)
{
A[i][n] -= A[j][n] * A[i][j];
}
A[i][n] /= A[i][i];
}
}
int main()
{
int n;
scanf("%d", &n);
for(int i = ; i <= n; i++)
for(int j = ; j < n; j++)scanf("%lf", &a[i][j]);
for(int i = ; i <= n; i++)
{
for(int j = ; j < n; j++)
{
tmp[i - ][n] -= a[][j] * a[][j];
tmp[i - ][n] += a[i][j] * a[i][j];
}
for(int j = ; j < n; j++)
tmp[i - ][j] = 2.0 * (a[i][j] - a[][j]);
}
gauss(tmp, n);
for(int i = ; i < n; i++)
{
if(i == )printf("%.3lf", tmp[i][n]);
else printf(" %.3lf", tmp[i][n]);
}
puts("");
return ;
}

BZOJ 1013 球形空间产生器sphere 高斯消元的更多相关文章

  1. BZOJ 1013: [JSOI2008]球形空间产生器sphere 高斯消元

    1013: [JSOI2008]球形空间产生器sphere Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/Judg ...

  2. 【BZOJ 1013】【JSOI2008】球形空间产生器sphere 高斯消元基础题

    最基础的高斯消元了,然而我把j打成i连WA连跪,考场上再犯这种错误就真的得滚粗了. #include<cmath> #include<cstdio> #include<c ...

  3. BZOJ-1013 球形空间产生器sphere 高斯消元+数论推公式

    1013: [JSOI2008]球形空间产生器sphere Time Limit: 1 Sec Memory Limit: 162 MB Submit: 3662 Solved: 1910 [Subm ...

  4. lydsy1013: [JSOI2008]球形空间产生器sphere 高斯消元

    题链:http://www.lydsy.com/JudgeOnline/problem.php?id=1013 1013: [JSOI2008]球形空间产生器sphere 时间限制: 1 Sec  内 ...

  5. [bzoj1013][JSOI2008][球形空间产生器sphere] (高斯消元)

    Description 有一个球形空间产生器能够在n维空间中产生一个坚硬的球体.现在,你被困在了这个n维球体中,你只知道球 面上n+1个点的坐标,你需要以最快的速度确定这个n维球体的球心坐标,以便于摧 ...

  6. BZOJ1013球形空间产生器sphere 高斯消元

    @[高斯消元] Description 有一个球形空间产生器能够在n维空间中产生一个坚硬的球体.现在,你被困在了这个n维球体中,你只知道球 面上n+1个点的坐标,你需要以最快的速度确定这个n维球体的球 ...

  7. bzoj1013球形空间产生器sphere 高斯消元(有系统差的写法

    Description 有一个球形空间产生器能够在n维空间中产生一个坚硬的球体.现在,你被困在了这个n维球体中,你只知道球面上n+1个点的坐标,你需要以最快的速度确定这个n维球体的球心坐标,以便于摧毁 ...

  8. 【BZOJ1013】球形空间产生器(高斯消元)

    [BZOJ1013]球形空间产生器(高斯消元) 题面 Description 有一个球形空间产生器能够在n维空间中产生一个坚硬的球体.现在,你被困在了这个n维球体中,你只知道球 面上n+1个点的坐标, ...

  9. BZOJ_1013_[JSOI2008]_球形空间产生器_(高斯消元)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1013 n维空间,给出球上n+1个点的n维坐标,求球心坐标. 提示:给出两个定义:1. 球心:到 ...

随机推荐

  1. WPF 用户控件嵌入网页

    WPF使用用户控件嵌入网页,直接使用WebBrowser或Frame会产生报错,报错信息如下: 1.使用WebBrowser,<WebBrowser Source="http://19 ...

  2. js 写日期选择器

    <html> <head> <title>Js日期选择器并自动加入到输入框中</title> <meta http-equiv="con ...

  3. Java8增强的Map集合

    Map集合简介 Map用于保存具有映射关系的数据,因此Map集合里保存着两组值,一组值用于保存Map里的key,另外一组用于保存Map里的vlaue,key和value都可以是任何引用类型的数据. M ...

  4. Spring 中的Enum HttpStatus 及HTTP状态码

    官方API https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/HttpStatus.htm ...

  5. 【SSH网上商城项目实战23】完成在线支付功能

     转自: https://blog.csdn.net/eson_15/article/details/51464415 上一节我们做好了支付页面的显示,从上一节支付页面显示的jsp代码中可以看出,当用 ...

  6. HBase—列族数据库的术语

    1. 列族数据库的基本组件 键空间,行键,列,列族 2. 什么是键空间 keyspace? 键空间 keyspace 是列族数据库的顶级数据结构,它在逻辑上能够容纳列族,行键以及与之相关的其他数据结构 ...

  7. K:hash的应用场景

    本博文主要用于讲解Hash的应用场景 Hash主要应用于数据结构中和密码学中. 用于数据结构时,主要是为了提高查询的效率,这就对速度比较重视,对抗碰撞不太看中,只要保证hash均匀分布就可以. 在密码 ...

  8. C#画个控件,指定字符特殊颜色显示

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. PAT 1074. Reversing Linked List

    #include <cstdio> #include <cstdlib> #include <iostream> #include <unordered_ma ...

  10. Oracle Metadata

    http://www.devart.com/dotconnect/oracle/articles/metadata.htmlhttp://dcx.sybase.com/1101/en/dbprogra ...