A. Balanced Product
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
We say a positive integer x
is balanced if there exist two positive integers a
and b
such that:
a × b
=x
and
|a − b|
≤1
In other words, x
is the product of two equal or consecutive positive integers.
You are given a positive integer n
. Your task is to count how many integers x
satisfy the following conditions: 1 ≤ x ≤ n
and x
is balanced.
Input
A single integer n
,(1 ≤ n ≤ \(10^9\))
Output
Print a single integer — the number of balanced integers between 1
and n
, inclusive.
Sample
Input | Output |
---|---|
|
|
Explanation
Balanced numbers ≤ 15:
1 = 1 × 1
2 = 1 × 2
4 = 2 × 2
6 = 2 × 3
9 = 3 × 3
12 = 3 × 4
Total balanced numbers: 6
Information
- ID
- 1191
- Difficulty
- 3
- Category
- (None)
- Tags
- (None)
- # Submissions
- 123
- Accepted
- 61
- Accepted Ratio
- 50%
- Uploaded By
Related
In following contests: