题目描述:
162 1 23 1 367 1 2100 1 28 6 89 6 810 6 811 6 812 6 813 6 814 6 815 6 816 6 81314 6 81994 1 131994 7 12 Sample OutputCase #1: IakaCase #2: YuwgnaCase #3: YuwgnaCase #4: IakaCase #5: IakaCase #6: IakaCase #7: YuwgnaCase #8: YuwgnaCase #9: IakaCase #10: IakaCase #11: YuwgnaCase #12: YuwgnaCase #13: IakaCase #14: YuwgnaCase #15: IakaCase #16: Iaka题目理解:代码:#include <iostream>#include <cmath>using namespace std;int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}int main(){ int t; cin>>t; for(int i=1;i<=t;i++) { int n,a,b; cin>>n>>a>>b; cout<<"Case #"<<i<<": "; int tmp=gcd(a,b); if(tmp==1) { if(n%2) cout<<"Yuwgna"<<endl; else cout<<"Iaka"<<endl; } else { int ans=n/tmp; if(ans%2) cout<<"Yuwgna"<<endl; else cout<<"Iaka"<<endl; } } return 0;}
新闻热点
疑难解答