302074: CF393B. Three matrices

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

Description

Three matrices

题意翻译

杨楚比正在学习线性方程组,他提出了一个很难的问题让你来做。他给你一个矩阵 W,你需要根据如下要求生成矩阵 A,B: - 对于 $\forall_{i,j}$,有 $A_{i,j}$=$A_{j,i}$; - 对于 $\forall_{i,j}$,有 $B_{i,j}$=$-B_{j,i}$; - 对于 $\forall_{i,j}$,有 $W_{i,j}$=$A_{i,j}$+$B_{i,j}$。 你能解决这个难题吗? ### 输入格式 输入一个 n*n 的矩阵,即 W 矩阵。 ### 输出格式 输出两个 n*n 的矩阵,即 A,B 矩阵,注意每一个数都要保留至小数点后第8位。 只要您的结果与真实结果相差不到 $10^{-4}$,我们将把您的结果判对。

题目描述

Chubby Yang is studying linear equations right now. He came up with a nice problem. In the problem you are given an $ n×n $ matrix $ W $ , consisting of integers, and you should find two $ n×n $ matrices $ A $ and $ B $ , all the following conditions must hold: - $ A_{ij}=A_{ji} $ , for all $ i,j $ $ (1<=i,j<=n) $ ; - $ B_{ij}=-B_{ji} $ , for all $ i,j $ $ (1<=i,j<=n) $ ; - $ W_{ij}=A_{ij}+B_{ij} $ , for all $ i,j $ $ (1<=i,j<=n) $ . Can you solve the problem?

输入输出格式

输入格式


The first line contains an integer $ n $ $ (1<=n<=170) $ . Each of the following $ n $ lines contains $ n $ integers. The $ j $ -th integer in the $ i $ -th line is $ W_{ij} $ $ (0<=|W_{ij}|&lt;1717) $ .

输出格式


The first $ n $ lines must contain matrix $ A $ . The next $ n $ lines must contain matrix $ B $ . Print the matrices in the format equal to format of matrix $ W $ in input. It is guaranteed that the answer exists. If there are multiple answers, you are allowed to print any of them. The answer will be considered correct if the absolute or relative error doesn't exceed $ 10^{-4} $ .

输入输出样例

输入样例 #1

2
1 4
3 2

输出样例 #1

1.00000000 3.50000000
3.50000000 2.00000000
0.00000000 0.50000000
-0.50000000 0.00000000

输入样例 #2

3
1 2 3
4 5 6
7 8 9

输出样例 #2

1.00000000 3.00000000 5.00000000
3.00000000 5.00000000 7.00000000
5.00000000 7.00000000 9.00000000
0.00000000 -1.00000000 -2.00000000
1.00000000 0.00000000 -1.00000000
2.00000000 1.00000000 0.00000000

Input

题意翻译

杨楚比正在学习线性方程组,他提出了一个很难的问题让你来做。他给你一个矩阵 W,你需要根据如下要求生成矩阵 A,B: - 对于 $\forall_{i,j}$,有 $A_{i,j}$=$A_{j,i}$; - 对于 $\forall_{i,j}$,有 $B_{i,j}$=$-B_{j,i}$; - 对于 $\forall_{i,j}$,有 $W_{i,j}$=$A_{i,j}$+$B_{i,j}$。 你能解决这个难题吗? ### 输入格式 输入一个 n*n 的矩阵,即 W 矩阵。 ### 输出格式 输出两个 n*n 的矩阵,即 A,B 矩阵,注意每一个数都要保留至小数点后第8位。 只要您的结果与真实结果相差不到 $10^{-4}$,我们将把您的结果判对。

加入题单

算法标签: