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

杨辉三角的变形

http://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43

真.找规律

/*
1 0 0 0 0 0
1 1 1 0 0 0
1 2 3 2 1 0 0 0
1 3 6 7 6 3 1 0
1 4 10

*/
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int temp = -1;
        if(n==1 || n==2){
            temp = -1;
        }
        else if(n % 2 != 0){
            temp = 2;
        }
        else if((n/2) % 2 == 0){
            temp = 3;
        }
        else{
            temp = 4;
        }
        
        System.out.println(temp);
    }
}
全部评论

相关推荐

投递华为等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务