1088 三人行 (20分)

#include <math.h>
#include <iostream>
using namespace std;

int main()
{
    int m,x,y,a,b=0,tmp1,tmp2;
    double c,tmp3,tmp4;
    cin>>m>>x>>y;
    for(a=99;a>=10;a--)
    {
        b=(a%10)*10+a/10;
        tmp1=abs(a-b)*y;
        tmp2=b*x;
        if(tmp1==tmp2)
            break;
    }
    if(a==9)
        cout<<"No Solution"<<endl;
    else
    {
        cout<<a<<" ";
        if(a>m)
            cout<<"Cong ";
        else if(a==m)
            cout<<"Ping ";
        else if(a<m)
            cout<<"Gai ";
        if(b>m)
            cout<<"Cong ";
        else if(b==m)
            cout<<"Ping ";
        else if(b<m)
            cout<<"Gai ";
        tmp3=b;tmp4=y;
        c=tmp3/tmp4;
        if(c>m)
            cout<<"Cong";
        else if(c==m)
            cout<<"Ping";
        else if(c<m)
            cout<<"Gai";
    }
    return 0;
}

 

posted @ 2020-02-07 09:26  QRain  阅读(139)  评论(0)    收藏  举报