Count Perfect Squares
EasyPractice library · +10 XPmathloops
Given a list of N integers, count how many of them are perfect squares. A perfect square is an integer that is the square of an integer (e.g., 1, 4, 9, 16 are perfect squares).
Input
The first line contains an integer N. The second line contains N space-separated integers.
Output
Print a single integer, the count of perfect squares in the given list.
Constraints
1 <= N <= 1000, 1 <= integer <= 10^6.
Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests
Example 1
Input
5 1 2 4 8 9
Output
3
4, 9, and 1 are perfect squares.
Example 2
Input
3 10 12 15
Output
0
None of the numbers are perfect squares.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
5 1 2 4 8 9
Example 2 input
3 10 12 15