题解 | #杨辉三角的变形#
杨辉三角的变形
https://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43
//本题的思路是先构建,再搜寻,因为本题不是标准的杨辉三角,所以不是方阵
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int n;
cin >> n;
//构造杨辉三角变形
if(n == 1 || n==2)
{ cout << -1 << endl;
return 0;}
if(n%2 == 1)
{
cout << 2<< endl;
return 0;
}
if(n%4 == 0)
{
cout << 3 << endl;
return 0;
}
else
{
cout << 4 << endl;
return 0;
}
}
查看14道真题和解析
顺丰集团工作强度 276人发布