CF #230 (Div. 2) B

来源:互联网 发布:caffe 用训练好的模型 编辑:程序博客网 时间:2024/04/30 00:23

这个简单,x+y=a  ,  x-y=b     求x,y

大概就是这东西


B. Three matrices
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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:

  • Aij = Aji, for all i, j (1 ≤ i, j ≤ n);
  • Bij =  - Bji, for all i, j (1 ≤ i, j ≤ n);
  • Wij = Aij + Bij, for all i, j (1 ≤ i, j ≤ n).

Can you solve the problem?

Input

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 Wij(0 ≤ |Wij| < 1717).

Output

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 Win 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.

Sample test(s)
input
21 43 2
output
1.00000000 3.500000003.50000000 2.000000000.00000000 0.50000000-0.50000000 0.00000000
input
31 2 34 5 67 8 9
output
1.00000000 3.00000000 5.000000003.00000000 5.00000000 7.000000005.00000000 7.00000000 9.000000000.00000000 -1.00000000 -2.000000001.00000000 0.00000000 -1.000000002.00000000 1.00000000 0.00000000
#include <cstdio>#include <iostream>#include <string.h>#include <stdlib.h>#include <fstream>#include <math.h>#include <queue>#include <algorithm>#define INF 0x3f3f3f3fusing namespace std;double w[175][175];double a[175][175];double b[175][175];int main(){//freopen ("input.txt","r",stdin);int n;cin>>n;for (int i = 1; i <= n; ++i)for (int j = 1; j <= n; ++j){cin>>w[i][j];if(i==j)a[i][i]=w[i][i],b[i][i]=0;}for (int i = 1; i <= n; ++i)for (int j = 1; j <= n; ++j)if(i!=j){b[i][j]=(w[i][j]-w[j][i])/2.0;a[i][j]=(w[i][j]+w[j][i])/2.0;}for (int i = 1; i <= n; ++i){for (int j = 1; j <= n-1; ++j)printf("%.8f ",a[i][j]);printf("%.8f\n",a[i][n]);}for (int i = 1; i <= n; ++i){for (int j = 1; j <= n-1; ++j)printf("%.8f ",b[i][j]);printf("%.8f\n",b[i][n]);}return 0;}


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 苹果电量跳电怎么办 ipad需要激活锁怎么办 电脑应用软件打不开了怎么办? ipad屏幕黑屏了怎么办 ipad挂机黑屏怎么办啊 ipad拍照坏了怎么办 ipad更新系统黑屏怎么办 苹果8卡机后黑屏怎么办 平板电脑开机黑屏怎么办 ipad黑屏有微光怎么办 苹果手机发热黑屏怎么办 ipadair开不了机怎么办 ipad3开不了机怎么办 ipad电源键失灵怎么办 ipad开关键失灵怎么办 ipadair关不了机怎么办 联想电脑开不了机怎么办 ipad来不了机怎么办 深圳车牌租用怎么办的 电脑连wiwf老掉线怎么办 电脑要设置密码怎么办 苹果笔记本电脑忘记密码怎么办 换了外屏有缝隙怎么办 苹果7屏幕松动怎么办 平板电脑屏幕一直闪怎么办 平板电脑屏幕模糊了怎么办 平板电脑模糊怎么办啊 苹果没有声音了怎么办 微信视频回声怎么办 苹果手机总卡机不动怎么办 苹果手机不掉电怎么办 iphonex屏幕漏液怎么办 苹果6sp充不进电怎么办 iphone6充电越少怎么办 苹果6不能充电怎么办 脸部苹果肌很大怎么办 液晶屏上有划痕怎么办 苹果手机屏幕翘起来怎么办? iphone5s翘屏了怎么办 lpad触屏失灵怎么办 平板一直重启怎么办