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