TopCoder problem "BisquareSums" used in TCHS SRM 17 (Division I Level One)



Problem Statement

    An integer b is a bisquare if two (possibly equal) integers x and y exist such that x2 + y2 = b. Given two ints, low and high, return the number of distinct bisquares between low and high, inclusive.
 

Definition

    
Class:BisquareSums
Method:getSums
Parameters:int, int
Returns:int
Method signature:int getSums(int low, int high)
(be sure your method is public)
    
 

Constraints

-low will be between 1 and 100, inclusive.
-high will be between low and 100, inclusive.
 

Examples

0)
    
1
5
Returns: 4
02 + 12 = 1

02 + 22 = 4

12 + 12 = 2

12 + 22 = 5
1)
    
7
7
Returns: 0
7 is not a bisquare.
2)
    
23
99
Returns: 30
3)
    
56
99
Returns: 16

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=6791

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10069&pm=6791

Writer:

eleusive

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Brute Force, Simple Math, Simple Search, Iteration