京东笔试 第二题 为什么一点也过不了

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long[] num=new long[n];
        for(int i=0;i<n;i++){
           num[i]=sc.nextLong();
        }
        for(int j=0;j<n;j++){
            long m=num[j];
            zhengchu(m);
        }
        
    }
    
    
    public static void zhengchu(long m){
        if(m%2==1){
            System.out.println("No");
        }else{
            long X=1;
            long Y=2;
            while(Y<=m){
            if(m%Y==0){
                X=m/Y;
                System.out.println(X+" "+Y);
                return;
            }else{
                Y=Y*2;
            }
            }
        }
    }

}


全部评论
你的X没有判断是奇数还是偶数
点赞 回复 分享
发布于 2018-04-10 09:31

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务