DMOPC '16 Contest 4 P1 - Fast Exponents

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem types

Molly's teacher assigned her very tedious homework:

Given an integer n_i, find out if it's a power of two or not.

Molly asks Andrew, but he would much rather play Geometry Dash, so he decides to enslave ask you to do it instead!

Input Specification

The first line will contain a single integer, N.
Lines 2 \dots N+1 will each contain an integer, n_i.

Output Specification

For each of the N integers, output T if it is a power of 2, otherwise output F.

Constraints

1 \le N \le 10^6
1 \le n_i < 2^{63}

Sample Input

2
1
3

Sample Output

T
F

Comments


  • 0
    SuperClash  commented on Dec. 21, 2020, 8:09 p.m. edited

    Tfw your brute force solution passes.


    • 1
      sushi  commented on Dec. 22, 2020, 5:33 p.m. edited

      It's not really brute force/brute force is intended, as your code runs in \mathcal{O}(N \log N), which would pass with the constraints.


  • -1
    Blackgaurdian3  commented on Aug. 1, 2020, 11:23 p.m.

    why am i getting WA for case 11?


    • -5
      YaySushi  commented on Aug. 2, 2020, 2:40 a.m.

      This comment is hidden due to too much negative feedback. Show it anyway.


      • 2
        Serendipity_skys  commented on Nov. 17, 2021, 2:05 a.m.

        Well yes but actually yes


        • 2
          Marshmellon  commented on Nov. 18, 2021, 12:01 a.m.

          Damn, I never knew Jimin did DMOJ


      • 6
        bariumlanthanum  commented on Dec. 21, 2020, 6:15 p.m.

        how can you be so contraversial but so true


  • -8
    mrglioula  commented on Nov. 24, 2017, 10:02 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • -1
      onetwothree  commented on Nov. 26, 2017, 2:03 a.m. edited

      First, you didn't use the boolean in your loop. Second, use scanf instead of cin. Finally, use long instead of int.


  • 0
    WilliamW_0627  commented on Feb. 16, 2017, 3:25 p.m.

    I submitted the exact same code twice and i got TLE (case 24) on one and AC on the other. What's up with that?


    • 6
      WallE256  commented on Feb. 16, 2017, 3:35 p.m. edited

      Please read this comment. In a nutshell, the judges don't produce the exact same result each time. As your program is really close to the timelimit, this kind of thing can happen.


  • 0
    Lunjun  commented on Feb. 15, 2017, 12:49 a.m.

    I implemented an algorithm using Python, but it did not pass. I implemented the same algorithm using C++, and it worked.


    • 2
      Kirito  commented on Feb. 15, 2017, 8:10 p.m.

      This problem has a lot of input, and input() is too slow; your code passes with sys.stdin.readline().