ITGUY06 - Editorial

Problem: Contest Page | CodeChef

DIFFICULTY:

EASY.

PROBLEM:

Chef has a number N, Cheffina challenges the chef to check the divisibility of all the permutation of N by 5. If any of the permutations is divisible by 5 then print 1 else print 0.

Program:

#include<bits/stdc++.h> 
using namespace std; 
 
int main() 
{ 
	
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
   	int t,n;
   	cin>>t;
   	while(t--){
   		string s;
   		cin>>s;
   		bool f=false;
   		for(int i=0;i<s.length();i++)if(s[i]=='0'||s[i]=='5'){
   			f=true;
   			break;
   		}
   		if(f)cout<<1<<"\n";
   		else cout<<0<<"\n";
   	}
}