Take string and check if any element of string is ‘0’ or ‘5’ … because 5 is divided by only 0 and 5… if any element of string is ‘0’ or ‘5’ print yes otherwise print no…
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int d = sc.nextInt();
String s = sc.next();
int count = 0;
for(int i=0 ; i<d ; i++){
if(s.charAt(i) == '0' || s.charAt(i) == '5'){
count++;
break;
}
else{
count=0;
}
}
if(count>0)
System.out.println("YES");
else
System.out.println("NO");
}
}
}
thx for ur efforts mam but i know only python can u tell me how to do it on python
t = int(input())
for _ in range(t):
d = int(input())
s = input()
count = 0
for i in range(d):
if s[i] == '0' or s[i] == '5':
count += 1
break
else:
count = 0
if count > 0:
print("YES")
else:
print("NO")
i hope you find this helpful.