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

32/152

Solve/Submission

Ranking

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

Your feedback is our precious!



Or call +88 02 9853138 for support