题解 | #杨辉三角的变形#
杨辉三角的变形
http://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43
import java.util.*;
public class Main{
// 找规律
// 奇数行:都为2
// 偶数行:n/2结果为奇数,返回4,else 返回3
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n == 1 || n == 2){
System.out.println(-1);
}else if(n % 2 != 0){
System.out.println(2);
}else{
int x = n / 2;
if(x % 2 == 0){
System.out.println(3);
}else{
System.out.println(4);
}
}
}
}