题解 | #杨辉三角的变形#

杨辉三角的变形

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;
        }
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务