DCP-418: Can You Answer Me? Back to All Problems

Medium Math > Counting


You are given an array **A** of length **N** consisting of integer numbers. Your task is to determine the value returned by following “Answer_Me” function. datatype Answer_Me(datatype N,datatype A[]) { datatype count=0; for(datatype i=1; i<=N; i++) { for(datatype j=i+1; j<=N; j++) { datatype product=A[i]*A[j]; if( IsPerfectSquare( product ) ==true ) { count++; } } } return count; } In above "Answer_Me" function, **IsPerfectSquare** is another function, which returns true if the value passed to its parameter is a Perfect Square number.<br> Note: **Perfect Square** is a number **N** such that there exists two integer numbers **X** and **Y**, not necessarily different, such that **X*Y=N**. Input: ------ Input starts with an integer **T (1<=T=5)**, denoting the number of test cases. Each case contains an integer **N (1 ≤ N ≤ 100000 )** denoting the number of elements of array **A**. <br>The next line will contain **N** integers separated a space, denoting the elements of the array A **(1<=Ai<=100)**. Output: ------- For each case of input, output the result of above function as described in the problem statement in a single line. Sample Input ------------ 1 5 1 2 4 3 5 Sample Output ------------- 1


Problem Setter:

Bishal Gautam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

72/506

Solve/Submission

Ranking

# User Language Timing
01 FariD Cpp14 0.01s
02 DynamicOvi Cpp 0.04s
03 clkjwdhc Cpp 0.04s
04 mhiceiuk Cpp 0.04s
05 daihan_mbstu Cpp14 0.04s
06 int_elligent Cpp 0.04s
07 pulak_ict_mbstu Cpp14 0.04s
08 mepromee Cpp 0.04s
09 alif_biswas Cpp 0.04s
10 hrOarr Cpp 0.04s
11 dot0 Cpp14 0.04s
12 Superstorm Cpp14 0.04s
13 mh755628 Cpp 0.04s
14 The_Viper Cpp 0.04s
15 Chayti_Saha98 Cpp 0.04s
16 t0whid Cpp14 0.05s
17 prateepm Cpp14 0.05s
18 Anubis Cpp 0.05s
19 emotionless Cpp14 0.05s
20 Bruteforcekid Cpp14 0.05s
21 sahedsohel Cpp 0.05s
22 _GhOstMan_ Cpp 0.05s
23 imAnik Cpp 0.05s
24 feodorv C 0.05s
25 mhiceiu Cpp 0.05s
26 mir003 Cpp 0.05s
27 mohibur Cpp 0.05s
28 burhan103335 Cpp 0.06s
29 Foysol_Ahmed Cpp 0.06s
30 shamimjucse Cpp 0.07s
31 Double_O Cpp 0.09s
32 by_default Cpp14 0.09s
33 subhashis_cse Cpp 0.10s
34 arman_ferdous Cpp 0.10s
35 Masum_ice Cpp 0.10s
36 nasib_mbstu Cpp 0.10s
37 moshiur_cse15 Cpp14 0.11s
38 ksohan Cpp 0.16s
39 Najat Cpp 0.22s
40 mahbubcseju Cpp 0.22s
41 tariqiitju Cpp14 0.23s
42 warriors_of_7 Cpp 0.29s
43 Mr_adnan Cpp 0.29s
44 ehsan_sshuvo96 Cpp 0.30s
45 ssavi Cpp 0.32s
46 anik_JU Cpp 0.34s
47 prodipdatta7 Cpp14 0.36s
48 Towfiq379 Cpp 0.36s
49 maxhasan Cpp 0.40s
50 emrul Cpp14 0.46s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support