# Help me in solving BIRDFARM problem

### 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