HDU 3571 N-dimensional Sphere( 高斯消元+ 同余 )
N-dimensional Sphere
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 668 Accepted Submission(s): 234
For each case there's one integer N on the first line.
Each of the N+1 following lines contains N integers x1, x2 ... xN describing the coordinate of a point on the N-dimensional sphere.
(0 <= T <= 10, 1 <= N <= 50, |xi| <= 10^17)
(It's guaranteed that all coordinate components of the answer are integers and there is only one solution and |Xi| <= 10^17)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
#define root 1,n,1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define lr rt<<1
#define rr rt<<1|1
typedef long long LL;
typedef pair<int,int>pii;
#define X first
#define Y second
const int oo = 1e9+;
const double PI = acos(-1.0);
const double eps = 1e- ;
const int N = ;
#define mod 200000000000000003LL
#define dif 100000000000000000LL LL Mod(LL x) {
if (x >= mod) return x - mod;
return x;
}
LL mul(LL a, LL b) {
LL res;
for (res = ; b; b >>= ) {
if (b & )
res = Mod(res + a);
a = Mod(a + a);
}
return res;
} void e_gcd( LL a , LL b , LL &d , LL &x , LL &y ) {
if( !b ){ d = a , x = , y = ; return ; }
e_gcd( b , a%b , d , y , x );
y -= x*(a/b);
} LL inv( LL a , LL n ){
LL d,x,y ;
e_gcd(a,n,d,x,y);
return ( x % n + n ) % n ;
} LL A[N][N] , g[N][N];
int n ; void Gauss() { for( int i = ; i < n ; ++i ) {
int r = i ;
for( int j = i ; j < n ; ++j ) {
if( g[j][i] ) { r = j ; break ; }
}
if( r != i ) for( int j = ; j <= n ; ++j ) swap( g[i][j] , g[r][j] ) ; LL INV = inv( g[i][i] , mod );
for( int k = i + ; k < n ; ++k ) {
if( g[k][i] ) {
LL f = mul( g[k][i] , INV );
for( int j = i ; j <= n ; ++j ) {
g[k][j] -= mul( f , g[i][j] );
g[k][j] = ( g[k][j] % mod + mod ) % mod ;
}
}
}
}
for( int i = n - ; i >= ; --i ){
for( int j = i + ; j < n ; ++j ){
g[i][n] -= mul( g[j][n] , g[i][j] ) , g[i][n] += mod , g[i][n] %= mod ;
}
g[i][n] = mul( g[i][n] , inv( g[i][i] , mod ) );
}
} void Run() { scanf("%d",&n);
memset( g , , sizeof g );
for( int i = ; i <= n ; ++i ) {
for( int j = ; j < n ; ++j ) {
scanf("%I64d",&A[i][j]);
A[i][j] += dif ;
}
} for( int i = ; i < n ; ++i ){
for( int j = ; j < n ; ++j ){
g[i][j] = Mod( A[n][j] - A[i][j] + mod );
g[i][j] = mul( g[i][j] , ) ;
g[i][n] = Mod( g[i][n] + mul( A[n][j] , A[n][j] ) );
g[i][n] = Mod( g[i][n] - mul( A[i][j] , A[i][j] ) + mod );
}
} Gauss();
printf("%I64d",g[][n]-dif);
for( int i = ; i < n ; ++i ){
printf(" %I64d",g[i][n]-dif);
}puts("");
} int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif // LOCAL
int cas = , _ ; scanf("%d",&_ );
while( _-- ){
printf("Case %d:\n",cas++); Run();
}
}
HDU 3571 N-dimensional Sphere( 高斯消元+ 同余 )的更多相关文章
- HDU.3571.N-dimensional Sphere(高斯消元 模线性方程组)
题目链接 高斯消元详解 /* $Description$ 在n维空间中给定n+1个点,求一个点使得这个点到所有点的距离都为R(R不给出).点的任一坐标|xi|<=1e17. $Solution$ ...
- BZOJ-1013 球形空间产生器sphere 高斯消元+数论推公式
1013: [JSOI2008]球形空间产生器sphere Time Limit: 1 Sec Memory Limit: 162 MB Submit: 3662 Solved: 1910 [Subm ...
- BZOJ 1013: [JSOI2008]球形空间产生器sphere 高斯消元
1013: [JSOI2008]球形空间产生器sphere Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/Judg ...
- HDU 5755 Gambler Bo(高斯消元)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5755 [题目大意] 一个n*m由0,1,2组成的矩阵,每次操作可以选取一个方格,使得它加上2之后对 ...
- HDU 4818 RP problem (高斯消元, 2013年长春区域赛F题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4818 深深地补一个坑~~~ 现场赛坑在这题了,TAT.... 今天把代码改了下,过掉了,TAT 很明显 ...
- ACM学习历程—HDU 3949 XOR(xor高斯消元)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3949 题目大意是给n个数,然后随便取几个数求xor和,求第k小的.(重复不计算) 首先想把所有xor的 ...
- lydsy1013: [JSOI2008]球形空间产生器sphere 高斯消元
题链:http://www.lydsy.com/JudgeOnline/problem.php?id=1013 1013: [JSOI2008]球形空间产生器sphere 时间限制: 1 Sec 内 ...
- [bzoj1013][JSOI2008][球形空间产生器sphere] (高斯消元)
Description 有一个球形空间产生器能够在n维空间中产生一个坚硬的球体.现在,你被困在了这个n维球体中,你只知道球 面上n+1个点的坐标,你需要以最快的速度确定这个n维球体的球心坐标,以便于摧 ...
- hdu 5833 Zhu and 772002 高斯消元
Zhu and 772002 Problem Description Zhu and 772002 are both good at math. One day, Zhu wants to test ...
随机推荐
- 基于TI 多核DSP 的大数据智能计算处理解决方案
北京太速科技有限公司 大数据智能计算,是未来的一个发展趋势,大数据计算系统主要完成数据的存储和管理:数据的检索与智能计算. 特别是在智能城市领域,由于人口聚集给城市带来了交通.医疗.建筑等各方面的压力 ...
- 微信小程序(13)--页面滚动到某个位置添加类效果
微信小程序页面滚动到某个位置添加类,盒子置顶效果. <!-- vh,是指CSS中相对长度单位,表示相对视口高度(Viewport Height),1vh = % * 视口高度 --> &l ...
- Python3.5-20190530-unittest模块
>>> dir(unittest) #所有的属性和方法 ['BaseTestSuite', 'FunctionTestCase', 'SkipTest', 'TestCase', ' ...
- 前端每日实战:50# 视频演示如何用纯 CSS 创作一个永动的牛顿摆
效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/qKmGaJ 可交互视频教程 此视频 ...
- create-react-app按需引入antd-mobile
1.引入 react-app-rewired 并修改 package.json 里的启动配置: npm i react-app-rewired@2.0.2-next.0 // 需要安装低版本 否则np ...
- mybatis源码分析之03SqlSession的创建
在上一篇中,说到了mybatis是如何构造一个SqlSessionFactory实例的,顾名思意,SqlSessionFactory就是用于创建SqlSession的工厂类. 好,现在我们接着昨天的来 ...
- 拦截Restful API的三种方式
如题, 方式有三种. (1). 过滤器filter javaEE规范 (2). 拦截器interceptor springmvc提供 (3). 切片 aspect 一. Filter使用示例 impo ...
- Oracle 的trim,ltrim,rtrim函数的区别
该函数共有两种作用:第一种,即大家都比较熟悉的去除空格.例子:--TRIM去除指定字符的前后空格SQL> SELECT TRIM(' dd df ') FROM dual;TRIM('DDDF' ...
- qt编程参考资料
https://qtguide.ustclug.org/
- react教程 — redux
一.概念: http://caibaojian.com/react/redux-basic.html 或 https://www.cnblogs.com/maopixin ...