#C12680. Perfect Squares in Descending Order
Perfect Squares in Descending Order
Perfect Squares in Descending Order
Given an integer n, your task is to print all the perfect squares from 1 to n (inclusive) in descending order. A perfect square is an integer that is the square of some integer (for example, 1, 4, 9, 16, etc.). If n is less than 1, then there are no perfect squares in the range and you should output nothing.
Examples:
- If n = 16, then the output should be:
16 9 4 1
- If n = 20, then the output should be:
16 9 4 1
- If n = 5, then the output should be:
4 1
- If n < 1, output nothing.
The mathematical condition for a perfect square is given by \( i^2 \) where \( i \) is an integer and \( i^2 \leq n \). The algorithm should compute the integer part of \( \sqrt{n} \) and then generate the squares in descending order.
inputFormat
Input is given from stdin as a single integer n.
Constraints:
- n is an integer.
outputFormat
Output to stdout a sequence of perfect squares in descending order, separated by a single space. If there is no valid perfect square (i.e. n < 1), output nothing.
## sample16
16 9 4 1