题解 | #杨辉三角的变形#
杨辉三角的变形
https://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextLine()) { int n = Integer.parseInt(in.nextLine()); int res = 0; if (n == 1 || n == 2) { res = -1; } else { switch ((n - 2) % 4) { case 1 : case 3 : res = 2; break; case 2 : res = 3; break; case 0 : res = 4; break; default: break; } } System.out.println(res); } } }