题目:https://pintia.cn/problem-sets/994805260223102976/problems/1038429286185074688
#include<iostream>
#include<math.h>
using namespace std;
int reverse(int n)
{
int i = n % 10;
int j = (n - n % 10) / 10;
int res = i * 10 + j;
return res;
}
void compare(int m, int b)
{
if (m < b)
cout << "Cong ";
else if (m == b)
cout << "Ping ";
else
cout << "Gai ";
}
int main()
{
int M, x, y;//
cin >> M >> x >> y;
int jia, yi,c=0;
float bing;
for (jia = 99;jia >= 10;jia--)
{
yi = reverse(jia);
bing = 1.0*yi / y;
if (abs((jia - yi)) / x == bing)
{
c++;
break;
}
else
{
continue;
}
}
if (c == 0)
{
cout << "No Solution";
}
else
{
cout << jia << " ";
compare(M, jia);
compare(M, yi);
if (M < bing)
cout << "Cong";
else if (M == bing)
cout << "Ping";
else
cout << "Gai";
}
return 0;
}
//18 有一个测试点没过