flower


      Topic link: http://acm.zzuli.edu.cn/problem.php?id=2261

      The title says that there may be multiple situations, but I think there can only be one answer, so I ignore that sentence. The idea is to first find the value of a according to the three equations, and then use the value of a to traverse the first position of the matrix. One line evaluates the other values.


AC code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int MAP[1005][1005];
int n;

intmain()
{
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%d",&MAP[i][j]);
    }
  }
  int x = MAP[0][1];
  int y = MAP[0][2];
  int z = MAP[1][2];
  int a = (x+y-z)/2;
  printf("%d ",a);
  for(int i=1;i<n;i++){
    printf("%d%c",MAP[0][i] - a,i==n-1?'\n':' ');
  }
  return 0;
}



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324686534&siteId=291194637