#CT0000061. Đếm số chính phương trong đoạn (Count Perfect Squares in an Interval)
Đếm số chính phương trong đoạn (Count Perfect Squares in an Interval)
Count Perfect Squares in an Interval
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer is called a perfect square if it is the square of a positive integer. For example, are perfect squares.
Given two positive integers and , count the perfect squares in the interval . Equivalently, count the integers such that and there exists a positive integer with .
Input
One line contains two positive integers and .
Output
Print one integer: the number of perfect squares in .
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): .
Examples
Example 1
Input
1 10
Output
3
Explanation
The perfect squares in are , , and , so the answer is .
Example 2
Input
25 25
Output
1
Explanation
The interval contains only . Since , exactly one value is a perfect square.
Example 3
Input
999999999999999999 1000000000000000000
Output
1
Explanation
We have , while . Hence only is a perfect square in the given interval.