题解 | 杨辉三角的变形
杨辉三角的变形
https://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43
#include <iostream> using namespace std; int main() { int n;cin>>n; if(n==1||n==2){ cout<<-1<<'\n'; return 0; } else{ if(n%2){ cout<<2; } else if(n%2==0&&n%4==0){ cout<<3; } else{ cout<<4; } } return 0; } // 64 位输出请用 printf("%lld")
当n<3时,没有偶数,输出-1;
当n为奇数时,第一个偶数位置在第二,输出2;
当n为偶数且能被4整除时,第一个偶数位置在第三,输出3;
当n为偶数但不能被4整除时,偶数位置在第四,输出4
活动地址https://www.nowcoder.com/discuss/726480854079250432
#牛客春招刷题训练营#