Assuming that the bottom layer is the first layer, we can see that the first layer is all odd, and the number of the second after the prime factor decomposition is 0, in turn up, the number of the second prime factor after decomposition is 1.2.3.4... the difference between the number on the N layer and the number on the leftmost and rightmost is the power of the N-1 of 2-1, so this question is to find the number of the second after the factorization prime factor.
In the first place, I used the method of Division 2 in sequence. Then I timed out and suddenly thought of the lowbit method in the tree array. Then I got the result by using N & (-N) directly.
# Include <cstdio> # include <math. h> using namespace STD; int main () {int ncase; scanf ("% d", & ncase); While (ncase --) {int N; scanf ("% d", & N); int K = N & (-N); k --; printf ("% d \ n", n-k, N + k);} return 0 ;}