Perfect Squares

Interview

Time limit1sMemory limit128 MB

Summary
Given N, count ordered pairs (A, B) with 1 <= B <= A <= 500 and A^2 - B^2 = N.
Level

Easy3 of 10

Topics
Brute force, Math, Number theory, Implementation
Solved
No attempts yet

Problem

Sanggeun and Seonyeong are playing a number-guessing game. First, Sanggeun picks two positive integers AA and BB with 1≤B≤A≤5001 \le B \le A \le 500. Seonyeong must then guess the numbers Sanggeun picked.

Sanggeun gives Seonyeong the following hint:

The square of AA is exactly NN greater than the square of BB. (1≤N≤1,0001 \le N \le 1{,}000)

In other words, A2−B2=NA^2 - B^2 = N. For the given NN, write a program that counts the number of ordered pairs (A,B)(A, B) satisfying this condition.

Input

The first line contains an integer NN. (1≤N≤1,0001 \le N \le 1{,}000)

Output

Print, on one line, the number of ordered pairs (A,B)(A, B) that satisfy both the hint condition A2−B2=NA^2 - B^2 = N and 1≤B≤A≤5001 \le B \le A \le 500.

Examples1

  1. Example 1

    Input
    15
    
    Expected output
    2