甲乙必定正整数而丙是任意的(从大到小遍历,成功直接return)。。。
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,p,q;
cin>>n>>p>>q;
int j,y;
double b;
//int flag = 0;
for(int i = 99;i>=10;i--){
j = i;
y = (i%10)*10+i/10;
if(abs(abs(j-y)/(double)p-y/(double)q)<=1e-6){
b = y/(double)q;
cout<<j;
if(n>j) cout<<" Gai";
else if(n==j) cout<<" Ping";
else if(n<j) cout<<" Cong";
if(n>y) cout<<" Gai";
else if(n==y) cout<<" Ping";
else if(n<y) cout<<" Cong";
if((double)n>b) cout<<" Gai";
else if(abs((double)n-b)<=1e-6) cout<<" Ping";
else if((double)n<b) cout<<" Cong";
//flag = 1;
return 0;
}
}
cout<<"No Solution";
return 0;
}