PAT 1088 三人行
注:丙可是小数
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
int main(){
int m, x, y, flag=0;
double ans[3];
cin>>m>>x>>y;
for(int i=99; i>9; i--){
int t=10*(i%10)+i/10;
if(double(abs(i-t))/x==double(t)/y){
flag=1;
ans[0]=i; ans[1]=t; ans[2]=double(t)/y;
break;
}
}
if(flag==0)
cout<<"No Solution"<<endl;
else{
cout<<ans[0];
for(int i=0; i<3; i++)
if(ans[i]==m) cout<<" Ping";
else if(ans[i]>m) cout<<" Cong";
else cout<<" Gai";
}
return 0;
}