2020 CCPC-Wannafly Winter Camp Day3 Div.1 & 2 (A balloon black) (Equation Solutions)
Time limit: C / C ++ 1 second, 2 seconds languages other
space restrictions: C / C ++ 262144K, other languages 524288K
64bit the IO the Format: LLD%
Title Description
There in front of a small D
black balloons.
The first hypothesis
highly black balloons is a positive integer
, Small D now know that any two balloons of different height and you help small D to restore the specific height of each balloon black thing?
Enter a description:
The first line of an integer
Next
lines of
integers, where the first
Line
integers represents
balloons and
height and a balloon. (when
When this number is
)。
, each of the input does not exceed the number of
. The only answer is to ensure that data.
Output Description:
Row
an integer that represents the answer.
The only guarantee an answer.
Example 1
Entry
5
0 3 4 5 6
3 0 5 6 7
4 5 0 7 8
5 6 7 0 9
6 7 8 9 0
Export
1 2 3 4 5
answer
To solve the equation, but there is an ingenious solution:
Three equations of the first term before the first use, reuse of items related to contact with the first equation.
Code
#include<stdio.h>
int main() {
int n, i, j, x, h1;
scanf("%d", &n);
int a[1001][1001];
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
scanf("%d", &a[i][j]);
x = a[2][3] - a[1][2];
h1 = (a[1][3] - x) / 2;
printf("%d ", h1);
for (i = 2; i <= n; i++)
printf("%d ", a[1][i] - h1);
return 0;
}