2020 CCPC-Wannafly Winter Camp Day3 Div.1 & 2 (A balloon black) (Equation Solutions)

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 n {n} black balloons.
The first hypothesis i {i} highly black balloons is a positive integer h i h_i , 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 n {n}
Next n {n} lines of n {n} integers, where the first i {i} Line j {j} integers represents i {i} balloons and j {j} height and a balloon. (when i = j {i=j} When this number is 0 {0} )。
2 n 1000 2 \ n \ the 1000 , each of the input does not exceed the number of 1 0 5 10^5 . The only answer is to ensure that data.

Output Description:

Row n {n} 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;
}
Published 163 original articles · won praise 54 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_42856843/article/details/104072439