解题思路:找出甲乙丙的关系,然后甲是两位数,答案要求取甲的最大数,则甲从99开始遍历
#include<bits/stdc++.h>
using namespace std;
int main(){
int m,x,y;
cin>>m>>x>>y;
int a,b,d;
double c;
bool flag=0;
for(int i=99;i>=10;i--){
int j=i%10*10+i/10;
if((j*x)==(abs(j-i)*y)){
a=i;
cout<<i<<' ';
b=j;
c=(b*1.0)/y;
flag=1;
break;
}
}
if(flag){
if(a>m)
cout<<"Cong"<<' ';
else if(a==m)
cout<<"Ping"<<' ';
else
cout<<"Gai"<<' ';
if(b>m)
cout<<"Cong"<<' ';
else if(b==m)
cout<<"Ping"<<' ';
else
cout<<"Gai"<<' ';
if(c>m)
cout<<"Cong";
else if(c==m)
cout<<"Ping";
else
cout<<"Gai";
}
else
cout<<"No Solution";
}
运行结果: