DCP-550: Interesting Lab Task Back to All Problems

Medium Math > Number Theory


**Mr. X** has given a lab task to his students. He has provided them with a pseudo code of a function. Their task is to implement a similar function that will give same output as the following function. Func(n) { ret = 0 for( i = 1; i < n; i++) { if( gcd(i,n) > 1) { ret = ret + i } } return ret } Input: ------ Input starts with an integer **T (1 ≤ T ≤ 1500)**, denoting the number of test cases. Each of the next **T** lines contain an integer **n (1 ≤ n ≤ 1,000,000,000)**. Output: ------- For each integer **n**, print the value of **Func(n)** in a line. Follow the output format of the sample. Sample Input ------------ 3 4 6 9 Sample Output ------------- 2 9 9


Problem Setter:

Fahim Shahriar Shakkhor

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

36/164

Solve/Submission

Ranking

# User Language Timing
01 feodorv C 0.02s
02 Rajib_119 Cpp 0.04s
03 Mubin_BUBT38 Cpp 0.05s
04 nadim_brur Cpp 0.05s
05 mahbubcseju Cpp 0.05s
06 shahjalalshohag Cpp14 0.05s
07 AmdSadi Cpp 0.05s
08 rifat_ikbal007 Cpp 0.05s
09 mash02 Cpp 0.06s
10 kzvd4729 Cpp14 0.06s
11 sayedgkm Cpp 0.08s
12 mobasshir Cpp 0.08s
13 Old_kernel Cpp14 0.08s
14 Raihanur_R Cpp 0.09s
15 nahid08 Cpp 0.09s
16 Bappy Cpp14 0.10s
17 liar Cpp 0.11s
18 Dalgerok Cpp14 0.12s
19 PKP_007 Cpp 0.12s
20 _c_k_r_ Cpp 0.13s
21 ssavi Cpp 0.14s
22 fire_tornado Cpp 0.15s
23 Double_O Cpp14 0.15s
24 ksohan Cpp 0.22s
25 tariqiitju Cpp14 0.37s
26 Taran Cpp14 0.38s
27 Bruteforcekid Cpp14 0.39s
28 snow_man Cpp14 0.39s
29 pulak_ict_mbstu Cpp14 0.40s
30 shamimjucse Cpp 0.40s
31 simantaturja Cpp 0.40s
32 shahadat191 Cpp14 0.41s
33 mamun02inf Cpp14 0.46s
34 mh755628 Cpp 0.48s
35 SakibAlamin Cpp14 0.68s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support