1. Title Description: Click to open the link
2. Problem-Solving ideas: finding regular questions. By observing easy to get the following recursion: (A[i][j] represents the layer I, the number of the brick of the J position)
(1) a[i+2][j+1]= (a[i][j]-a[i+2][j]-a[i+2][j+2])/2;
(2) a[i+1][j]=a[i+2][j+1]+a[i+2][j];
(3) a[i+1][j+1]=a[i+2][j+1]+a[i+2][j+2];
3. Code:
#define _crt_secure_no_warnings #include <iostream> #include <algorithm> #include <string> #include <sstream> #include <set> #include <vector> #include <stack> #include <map> #include < queue> #include <deque> #include <cstdlib> #include <cstdio> #include <cstring> #include < cmath> #include <ctime> #include <functional>using namespace std; #define N 9int A[n][n];int Main () {// Freopen ("Test.txt", "R", stdin), int t;cin >> t;while (t--) {memset (A, 0, sizeof (a)); for (int i = 0; i < 9; i+=2) fo R (Int j = 0; J < i + 1; j + + 2) CIN >> a[i][j];for (int i = 6; I >= 0; i-=2) {for (int j = 0; J < i + 1; j + = 2) {a[i + 2][j + 1] = (A[i][j]-a[i + 2][j]-a[i + 2][j + 2])/2;a[i + 1][j] = a[i + 2][j + 1] + a[i + 2][j];a[i + 1][ J + 1] = a[i + 2][j + 1] + a[i + 2][j + 2];}} for (int i = 0; i < 9;i++.) for (int j = 0; J < i + 1, j + +) printf ("%d%c", a[i][j], j = = I? ' \ n ': ');} return 0;}
Exercise 10-1 Brick UVa11040