SSR
Time limit2sMemory limit512 MB
Count ordered pairs (A, B) with A <= N and B <= M for which (sqrt(A) + sqrt(B))^2 is an integer.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
For two positive integers and , define .
Given two integers and , write a program that counts the ordered pairs with and for which is an integer.
Input
The first line contains and , separated by a space. ()
Output
Print the number of ordered pairs that satisfy the condition on the first line.