Help me in solving BIRDFARM problem

My issue

My code

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    int x,y,z;
	    cin>>x>>y>>z;
	    if(z%x==0 && z%y!=0){
	        cout<<"CHIKEN"<<endl;
	    }
	    else if(z%x!=0 && z%y==0){
	        cout<<"DUCK"<<endl;
	    }
	    else if(z%x==0 && z%y==0){
	        cout<<"ANY"<<endl;
	    }
	    else{
	        cout<<"NONE"<<endl;
	    }
	}
	return 0;
}

Problem Link: BIRDFARM Problem - CodeChef

@rick_662
CHICKEN spelling is wrong in your code .
Rest is correct

#include <iostream>
using namespace std;

int main() {
    
	int t;
	cin>>t;
	while(t--){
	    int n,x,y;
	    cin>>x>>y>>n;
	    if(n%x==0){
	        if(n%y==0){
	            cout<<"ANY"<<endl;
	        }
	        else{
	            cout<<"CHICKEN"<<endl;
	        }
	    }
	    else if(n%y==0){
	        if(n%x==0){
	            cout<<"ANY"<<endl;
	        }
	        else{
	            cout<<"DUCK"<<endl;
	        }
	    }
	    
	    else{
	        cout<<"NONE"<<endl;
	    }
	}
	

	return 0;
}

You only have to test whether β€˜n’ is completely divisible by β€˜x’ or β€˜y’.
If it is completely divisible by β€˜x’ then print CHICKEN.
If it is completely divisible by β€˜y’ then print DUCK.
If it is completely divisible by β€˜x’ as well β€˜y’ then print ANY.
If it is completely divisible by none then print NONE.

Hope this helps…

1 Like