VM7WC '16 #4 Bronze - Perfect Squares for Not-So-Perfect Cases

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

After writing so many problems and test cases, Jeffrey is having a horrible headache! However, he must finish writing the problems for the Seven Week Challenge. At this point, in this much pain, Jeffrey really doesn't care about how much the headache will affect the quality of his problems. He is happy and will feel better about himself as long as he gets them done.

Jeffrey is currently writing up a problem on numbers. He would like the users to classify all numbers from A to B (inclusive) based on the properties associated with the numbers. As a child prodigy, Jeffrey knows how to classify even and odd numbers, as well as prime and composite numbers. But after quitting Sunday Math, Jeffrey has forgotten how to identify if a number is a perfect square or not!

Of course, the users cannot know about this! Jeffrey must hide this fact and has come to you for help in identifying the perfect squares. Jeffrey will give you two integers, A and B, and would like to know how many perfect squares there are within the range (inclusive)! We consider 0 to be a perfect square.

Input Specification

The input consists of a line with two space-separated integers, A and B (-10\,000 \le A,B \le 10\,000).

Output Specification

An integer representing the number of perfect squares between A and B inclusive.

Sample Input

10 50

Sample Output



  • 0
    fyras1  commented on Feb. 1, 2016, 12:06 p.m.

    is 0 considered a perfect square ? i googled it up and different answers

    • 0
      JeffreyZ  commented on Feb. 1, 2016, 2:46 p.m.

      Didn't know it was ambiguous. Here, we considered 0 to be a perfect square.

      Problem statement updated.