I passed all the test cases…But couldn`t able to find optimized solution…Please help.
#include
using namespace std;
int sumodd, sumeven;
int sum( int n){
sumodd =sumeven =0;
int c=1;
while(n!=0){
if(c%2==0){
sumeven=sumeven+n%10;
}else{
sumodd=sumodd+n%10;
}
n=n/10;
c++;
}
if(sumeven%4 ==0 || sumodd%3 ==0){
cout<<“YES”<<endl;
}else{
cout<<“NO”<<endl;
}
return sumodd, sumeven;
}
int main(){
int n,N;
cin>>N;
while(N<=1000 && 0<=n<=1000000000){
for(int i=1; i<=N; i++){
cin>>n;
sum(n);
}
}
}