Join Regular Classroom : Visit ClassroomTech

Wipro NLTH Coding Solve | Garments company Apparel | Codewindow.in

The garments company Apparel wishes to open outlets at various locations. The company shortlisted several plots in these locations and wishes to select only plots that are square- shaped. Write an algorithm to help Apparel find the number of plots that it can select for its outlets.

Input
The first line of the input consists of an integer num0fMots, representing the number of plots shortlisted by the company for outlets (N). The second line consists of N space-separated integers – areal, areal, ….., areaN representing the area of the N plots selected for outlets.

Output
Print an integer representing the number of plots that will be selected for outlets.

Constraints:
0 < num0fPlots < 106
0 < area < 106
0 < i < num0fPlots

Example

Input:
8
79 77 54 81 48 34 25 16

Output:
3

Explanation:
The areas that are in square form are 81, 25 and 16. So, the output is 3.

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int sroot,c=0;
    for(i=0;i<n;i++)
    {
    for(sroot=2;sroot*sroot<a[i];sroot++)
    ;
    if(sroot*sroot==a[i])
    c++;
    }
    printf("%d",c);
}

Also Checkout

Recent Posts
Categories
Pages