@vigneshwaran99
The logic is if your number n contains any digit either 0 or 5 then we can made whole number divisible by 5 by taking it in front .
Here is the code int python for it , i hope u will get it.
for _ in range(int(input())):
a=int(input())
b=str(input())
if '0' in b or '5' in b:
print("Yes")
else:
print("NO")
thanks for ur efforts but actually i m not able to find how to rearrange the numbers for eg 505 055 550 like that can u pls provide me the code
@vigneshwaran99
The arrangement were not asked in the question if it is asked it will become much higher difficulty level question that requires recursion to solve .
according to question we have to ask for input and rearrange it in all possible ways and we should check if its multiple of 5
_python3
@vigneshwaran99
That will be the brute force approach but it still won’t require to rearrange it like it is asked whether u can rearrange it to from a multiple of 5 or not so if the digits of number contains atleast one 0 or one 5 then it is always possible to make it a multiple of 5 and else case it is not possible. So all u need is to check all the digits of N thats it.
As you demanded this is the solution:
though it is categorised under RTE when submitted.
PROGRAM BELOW___________
t = int(input("Enter number of test cases : "))
count=0
for i in range(0,t):
d = int(input(“enter number of digits :”))
n = list((input(“Enter number :”)))
a,b,c = int(n[0]),int(n[1]),int(n[2])
abc = ax100+bx10+c
bca = bx100+cx10+a
cab = cx100+ax10+b
bac= bx100+ax10+c
cba = cx100+bx10+a
acb = ax100+cx10+b
l = [abc,bca,cab,bac,cba,acb]
m =[]
for i in l:
if len(str(i))>2:
m.append(i)
for i in range(0,len(m)):
if m[i]%5==0 or m[i+1]%5==0 or m[i+2]%5==0:
print(‘yes’)
break
else:
print(‘no’)
break
NOTE: During writting this reply i noticed that “" is vanished from program after uploading so i used “x” istead of "” to show multiplication. If your are going to test this program kindly change x to “*” again. Hope it helps.
Hi vigneshwaran99, Did you got your answer?