# 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