電泡泡

## Problem B: SUME

Time Limit: 1 Sec   Memory Limit: 32 MB
Submit: 6   Solved: 5
[ Submit][ Status][ Web Board]

## Description

Once upon a time, there existed a sequence A  consisting of N positive integers. You don't know the
sequence itself, but you do know the sum of every two elements of the sequence. Find the sequence A!

## Input

The first line of input contains the positive integer N (2 ≤ N ≤ 1000).
Each of the following N lines contains N positive integers smaller than or equal to 100 000, forming
the table S. The following relations hold: S(i, j) = A [i] + A [j] for i ≠ j, and S(i, j) = 0 for i = j. Here S(i,
j) denotes the number in the ith  row and jth column of the table, and A [i] denotes the ith element of the

sequence A.

It is guaranteed that for any input data set there exists a unique sequence of positive integers A with
the given properties.

## Output

The   first   and   only   line   of   output   must   contain   the   required   sequence  A (in   the   form   of  N  space-
separated positive integers).

0 2

2 0

4

0 3 6 7

3 0 5 6

6 5 0 9

7 6 9 0

## Sample Output

1 1

2 1 4 5

``````#include  <iostream>
using namespace std;
int
main()
{
freopen("sume.data.in", "r", stdin);
freopen("test.out", "w", stdout);
int s, n, a[1010], ans[1010];
long long int ssum, sa;//注意越界问题
while(cin>>n){
sa=0;
ssum=0;
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
cin>>s;
ssum+=s;
if(i==1){
a[j]=s;
sa+=s;
}
}
}
ssum=(ssum/2)/(n-1);
if(sa==2){
ans[1]=1;
}
else{
ans[1]=(sa-ssum)/(n-2);
}

for(int i=2; i<=n; i++){
ans[i]=a[i]-ans[1];
}
for(int i=1; i<=n; i++){
cout<<ans[i];
if(i!=n){
cout<<" ";
}
}
cout<<endl;
}
return 0;
}``````

### 電泡泡

The Blocks Problem

2016/09/27
0
0
apache日志如何记录爬虫地址 日志格式化格式

apache需要记录爬虫记录来做SEO优化，找了好半天都没找到，各位谁有格式化代码麻烦给我一下，谢谢 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 如上......

2013/05/14
410
0
AppleScript 判断按键事件的脚本文章收集

AppleScript support for SplitPanes 来自：http://code.google.com/p/iterm2/issues/detail?id=559 Reported by samantha...@gmail.com , Jan 29, 2011 Hi, I would like to be able to sc......

FreeBlues
2013/12/17
0
0

2018/11/20
0
0
OpenJDK - JDK8 计划

oschina
2012/08/21
6.9K
26

5、redis分布式锁

18分钟前
3
0
OSChina 周日乱弹 —— 我重新说

Osc乱弹歌单（2019）请戳（这里） 【今日歌曲】 @宇辰OSC ：分享矢野立美的单曲《LOVE Theme from TIGA <M-2>》: 《LOVE Theme from TIGA <M-2>》- 矢野立美 手机党少年们想听歌，请使劲儿戳...

56
5
Java单例模式学习记录

JerryLin123

10
0
VSCODE 无法调试

VSCODE 无法调试 可以运行 可能的原因： GCC 的参数忘了加 -g

shzwork

5
0

Tiny熊

5
0