Submission #11819140


Source Code Expand

Copy
import fractions
K = int(input())
out = 0
L = [0]*K
gcd = [[0]*K for i in range(K)]
for i in range(1,K+1):
    for j in range(1,K+1):
        A = fractions.gcd(i,j)
        gcd[i-1][j-1] = A
        L[A-1]+=1


for i in range(1,K+1):
    for j in range(1,K+1):
        out+=gcd[i-1][j-1]*L[j-1]

print(out)

Submission Info

Submission Time
Task C - Sum of gcd of Tuples (Easy)
User Kthick
Language Python (3.8.2)
Score 300
Code Size 322 Byte
Status
Exec Time 82 ms
Memory 10872 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02
All 300 / 300 hand_01, large_01, large_02, large_03, large_04, large_05, random_01, random_02, random_03, random_04, random_05, sample_01, sample_02, small_01, small_02, small_03, small_04, small_05
Case Name Status Exec Time Memory
hand_01 26 ms 10372 KB
large_01 81 ms 10696 KB
large_02 78 ms 10736 KB
large_03 81 ms 10872 KB
large_04 82 ms 10800 KB
large_05 76 ms 10796 KB
random_01 33 ms 10572 KB
random_02 61 ms 10592 KB
random_03 44 ms 10704 KB
random_04 64 ms 10736 KB
random_05 39 ms 10760 KB
sample_01 29 ms 10368 KB
sample_02 81 ms 10820 KB
small_01 28 ms 10536 KB
small_02 27 ms 10548 KB
small_03 27 ms 10372 KB
small_04 28 ms 10480 KB
small_05 26 ms 10488 KB