Codechef : Problem name " Rearranging digits to get a multiple of 5 " solution in C#
=================================Solution====================================
using System;
public class Test
{
public static void Main()
{
int t=Convert.ToInt32(Console.ReadLine());
for(int i=0;i<t;i++){
int N=Convert.ToInt32(Console.ReadLine());
string str=Console.ReadLine();
if(str.Contains('0') || str.Contains('5'))
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
}
===============================Explanation=================================
If the string entered by the user contains character 0 or 5 then it is surely divisible by 5
Comments
Post a Comment