t=int(input())
for i in range(t):
sum=0
k,d0,d1=map(int, input().split())
l1=[d0,d1]
for i in range(2,k):
l1.append(0)
for j in range(0,i):
l1[i]+=l1[j]
l1[i]=l1[i]%10
for p in range(len(l1)):
sum+=l1[p]
if(sum%3==0):
print(“YES”)
else:
print(“NO”)
can you please give me hint what should i do if some test case has large inputs , actually it had done twice that my code does not work for large inputs
Problem is not with large inputs.But actually complexity.Here ur code will perform roughly 10^12 operations.But the max is 10^8.So you just have to come up with more optimal solution.