ITGUY03 - 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 2. If any of the permutations is divisible by 2 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]=='2'||s[i]=='4'||s[i]=='6'||s[i]=='8'){
   			f=true;
   			break;
   		}
   		if(f)cout<<1<<"\n";
   		else cout<<0<<"\n";
   	}
}