ALATE - LoC Aug 2017

Hello Guys,

I want to understand why my code is getting WA for the problem ALATE in LoC Aug 2017.
My solution compute for query 1 the function and store it in an array. I use a recursive method for that.
While computing the function, I store the divisors for each element. For example, if I compute func for x, for each i involved, I store x as a divisor of i (since i is always a multiple of x). For query 2, I update the value of func for the divisors of the x given.

Here is my code :

Sorry for my approximative English :).

You code is giving null pointer exception for this test case…

1 2
2 1 3
1 1

You can generate random testCase using this python testGenerator and check against existing AC solution… Keep parameters small to analyse your mistake…

import random
t = 1
print t
numLimit = 3
nLimit = 4
qLimit = 4
for _ in range(t):
    n = random.randint(1,nLimit)
    q = random.randint(1,qLimit)
    print n,q
    for __ in range(n-1):
        print random.randint(1,numLimit),
    print random.randint(1,numLimit)
    for __ in range(q):
        qType = random.randint(1,2)
        if qType == 1:
            print 1,random.randint(1,n)
            print 2,random.randint(1,n),random.randint(1,numLimit)

Hope this will help…

Thanks for your insight, @kauts_kanu :slight_smile: