Perfect Squares
InterviewTime limit1sMemory limit128 MB
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 and with . Seonyeong must then guess the numbers Sanggeun picked.
Sanggeun gives Seonyeong the following hint:
The square of is exactly greater than the square of . ()
In other words, . For the given , write a program that counts the number of ordered pairs satisfying this condition.
Input
The first line contains an integer . ()
Output
Print, on one line, the number of ordered pairs that satisfy both the hint condition and .