码迷,mamicode.com
首页 > 其他好文 > 详细

Aiiage Camp Day3 B Bipartite

时间:2018-02-11 18:07:17      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:art   math   and   system.in   gpo   cin   main   pre   题意   

题意

  给出T个N,判断哪些是2的整数次幂。

  T<=10, N<=1e100000.

 

题解

  N & (N - 1) == 0即为2的整数次幂。

  学好Java,做遍大数都不怕。

 1 import java.math.BigInteger;
 2 import java.util.Scanner;
 3 
 4 public class Main
 5 {
 6     public static void main(String[] args)
 7     {
 8         Scanner cin = new Scanner(System.in);
 9         int T;
10         T = cin.nextInt();
11         for (int ii = 0; ii < T; ++ii)
12         {
13             BigInteger n = cin.nextBigInteger();
14             if (n.compareTo(BigInteger.ZERO) > 0)
15             {
16                 BigInteger ans = n.and(n.subtract(BigInteger.ONE));
17                 if (ans.compareTo(BigInteger.ZERO) == 0)
18                     System.out.println("Yes");
19                 else
20                     System.out.println("No");
21             }
22             else
23             {
24                 System.out.println("No");
25             }
26         }
27     }
28 }

 

Aiiage Camp Day3 B Bipartite

标签:art   math   and   system.in   gpo   cin   main   pre   题意   

原文地址:https://www.cnblogs.com/aseer/p/8442521.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!