301382: CF259B. Little Elephant and Magic Square

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Little Elephant and Magic Square

题意翻译

## 题目描述 小象非常喜欢幻方。 幻方是一个3×3的表,每个单元格包含一些正整数。此时,表中所有行、列和对角线的整数之和相等。下图显示了幻方,其所有行、列和对角线中的整数之和等于15。 小象想起了一个幻方。他开始在一张纸上写这个正方形,但是当他写的时候,他忘记了幻方主对角线的所有三个元素。幸运的是,小象清楚地记得幻方的所有元素都没有超过10的5次方。 鉴于小象的笔记,帮助小象,恢复原来的幻方。 ## 输入格式 输入的前三行包含小象的笔记。第一行包含幻方第一行的元素。第二行包含第二行的元素,第三行是第三行。大象忘记的主要对角线元素用零表示。 保证音符正好包含三个零,并且它们都位于主对角线上。保证表中所有正数不超过10的5次方。 ## 输出格式 打印三行,每行打印三个整数——小象的幻方。如果有多个幻方,你可以打印其中任何一个。请注意,您打印的所有数字必须是正数,并且不超过10的5次方。 保证至少存在一个满足条件的幻方。

题目描述

Little Elephant loves magic squares very much. A magic square is a $ 3×3 $ table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals 15. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF259B/aae3f0346c9185d03e3596ca4724b5a92e85979b.png)The Little Elephant remembered one magic square. He started writing this square on a piece of paper, but as he wrote, he forgot all three elements of the main diagonal of the magic square. Fortunately, the Little Elephant clearly remembered that all elements of the magic square did not exceed $ 10^{5} $ . Help the Little Elephant, restore the original magic square, given the Elephant's notes.

输入输出格式

输入格式


The first three lines of the input contain the Little Elephant's notes. The first line contains elements of the first row of the magic square. The second line contains the elements of the second row, the third line is for the third row. The main diagonal elements that have been forgotten by the Elephant are represented by zeroes. It is guaranteed that the notes contain exactly three zeroes and they are all located on the main diagonal. It is guaranteed that all positive numbers in the table do not exceed $ 10^{5} $ .

输出格式


Print three lines, in each line print three integers — the Little Elephant's magic square. If there are multiple magic squares, you are allowed to print any of them. Note that all numbers you print must be positive and not exceed $ 10^{5} $ . It is guaranteed that there exists at least one magic square that meets the conditions.

输入输出样例

输入样例 #1

0 1 1
1 0 1
1 1 0

输出样例 #1

1 1 1
1 1 1
1 1 1

输入样例 #2

0 3 6
5 0 5
4 7 0

输出样例 #2

6 3 6
5 5 5
4 7 4

Input

题意翻译

## 题目描述 小象非常喜欢幻方。 幻方是一个3×3的表,每个单元格包含一些正整数。此时,表中所有行、列和对角线的整数之和相等。下图显示了幻方,其所有行、列和对角线中的整数之和等于15。 小象想起了一个幻方。他开始在一张纸上写这个正方形,但是当他写的时候,他忘记了幻方主对角线的所有三个元素。幸运的是,小象清楚地记得幻方的所有元素都没有超过10的5次方。 鉴于小象的笔记,帮助小象,恢复原来的幻方。 ## 输入格式 输入的前三行包含小象的笔记。第一行包含幻方第一行的元素。第二行包含第二行的元素,第三行是第三行。大象忘记的主要对角线元素用零表示。 保证音符正好包含三个零,并且它们都位于主对角线上。保证表中所有正数不超过10的5次方。 ## 输出格式 打印三行,每行打印三个整数——小象的幻方。如果有多个幻方,你可以打印其中任何一个。请注意,您打印的所有数字必须是正数,并且不超过10的5次方。 保证至少存在一个满足条件的幻方。

加入题单

算法标签: