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