Test instructions
45 stones are arranged, and the number on each stone is equal to the sum of the two numbers below to support it, and the remaining number is not expressed.
Analysis:
The first is to calculate the number of the bottom line, A71 = A81 + A82 = A91 + 2a92 + A93, the deformation gets A92 = (A71-A91-A93)/2.
And so on, you can get the number of the bottom line. With this "foundation", all the numbers can be counted.
1#include <cstdio>2 3 inta[Ten][Ten];4 5 intMain ()6 {7 //freopen ("In.txt", "R", stdin);8 intT;9scanf"%d", &T);Ten while(t--) One { A for(inti =1; I <=9; i + =2) - for(intj =1; J <= I; J + =2) -scanf"%d", &a[i][j]); the for(inti =2; I <=8; i + =2) -a[9][i] = (a[7][i-1]-a[9][i-1]-a[9][i+1])/2; - for(inti =8; I >=1; --i) - { + if((I &1) ==0) - { + for(intj =1; J <= I; ++j) AA[I][J] = a[i+1][J] + a[i+1][j+1]; at } - Else - { - for(intj =2; J <= I; J + =2) -A[I][J] = a[i+1][J] + a[i+1][j+1]; - } in } - to for(inti =1; I <=9; ++i) + { - for(intj =1; J < I; ++j) theprintf"%d", A[i][j]); *printf"%d\n", A[i][i]); $ }Panax Notoginseng - } the + return 0; A}code June
UVa 11040 (water problem) Add bricks in the wall