CCC '09 S1 - Cool Numbers

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2009 Stage 1, Senior #1

Eric likes interesting numbers like 64. It turns out that 64 is both a square and a cube, since 64=82 and 64=43. Eric calls these numbers cool. Write a program that helps Eric figure out how many integers in a given range are cool.

Input Specification

On the first line of input, you are given an integer a such that a1 and a108. On the second line of input, you are given an integer b such that ba and b108.

Output Specification

The output should be the number of cool numbers in the range a to b (inclusively: that is, a and b would count as cool numbers in the range if they were actually cool).

Sample Input 1

Copy
1
100

Sample Output 1

Copy
2

Sample Input 2

Copy
100
1000

Sample Output 2

Copy
1

Comments


  • -2
    CoderGrinder  commented on Dec. 13, 2024, 4:46 p.m.

    Bro I almost got this but it always exceeds my time limit.


    • -2
      Compro72  commented 47 days ago

      The amount of cool numbers from 1 to 100000000 isn't big. Try pre-computing all the cool numbers.