Hi,
Can anyone tell what is the problem cause I was getting the correct output but in starters 103 contest it was showing wrong.
Do I need to add recursion to it.
Code-
t=int(input())
for i in range(t):
n,m=map(int,input().split())
z=str(n)
k=1
for j in range(n):
if m%8==0:
print(m)
break
Hi, buddy. Actually, no. The problem is not going to be solved in this way. I solved the same problem. And I explained it right here: codechef.com/viewsolution/1025297287
Visit here. There, I explained this problem. I think, that would be helpful))
Gotcha, what is wrong with yours. You’re checking for only difference of 1. I mean, your code is just changing one of the characters by 1, which is not match the requirements of the problem. There is a rule that says, if the last 3characters combined is divisible by 8, this number is divisible by 8. For example, 1000 (or 1200, 1800, 1008) is divisible by 8 because 000 is divisible by 8. Didn’t you read my explains that is given in the link I provide? In my opinion, I explained it well there! Read this, that can understand more clear.