[Huawei OD test questions] Yang Hui's triangle deformation (C&Java&python) 100% pass rate

topic description

In the above triangular number matrix, there is only one number 1 in the first row, and each number in each of the following rows is exactly the number above it, the number in the upper left corner and the number in the upper right corner, and the sum of the three numbers (if there is no number, assuming that the number is 0).
Find the position of the first even number in row n. If there is no even number, output -1. For example, input 3, output 2, input 4, output 3, input 2, output -1

enter

Enter an int integer

output

Output returns the int value

sample 1

enter

4

output

3

Java code:

import java.util.*;

public 

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/130918467