题解 | 杨辉三角的变形
杨辉三角的变形
https://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43
#include <iostream> using namespace std; int main() { int n = 0; cin >> n; if (n <= 2) { cout << -1 << endl; } else { if (n % 2 == 0) { int num3 = n*(n - 1)/2;// 第N行第三个数的值必然符合1+2+3+...+n-1即n*(n-1)/2 if(num3 % 2){ cout << 4 << endl;//第N行第三个数的值为奇数则第四个必为偶数 }else{ cout << 3 << endl; } }else{ cout << 2 << endl;//奇数行 第二个数必为偶数 } } return 0; } // 64 位输出请用 printf("%lld")