خرید بک لینک

Vote count: 1

I am solving this problem in SPOJ which states that:

Let

enter image description here enter image description here

enter image description here

To this I wrote the following code but it takes polynomial time. How can I optimise this code to run in sublinear time if its possible

m=18446744073709551616

def gcd(a,b):
    if b==0:
        retu a
    else:
        retu gcd(b,a%b)

for i in range(int(raw_input())):
    n=int(raw_input())
    s=0
    for i in range(1,n+1):
        for j in xrange(i+1,n+1):
            s+=gcd(i,j)
    print s%m

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 1 ارديبهشت 1395 ساعت: 1:14

صفحه بندی