我的个人网站 Cheese的个人主页http://www.cheese.ren/
博客来源 PAT 乙级 1088 三人行-Cheese的个人博客PAT 乙级 1088 三人行 C++http://blog.cheese.ren/108
欢迎交换友链 :-)
#include <bits/stdc++.h>
using namespace std;
int invert(int a) {
string s;
s = to_string(a);
reverse(s.begin(), s.end());
return atoi(s.c_str());
}
void compare(int m, double a) {
if (m > a) {
cout << "Gai";
}
else if (m == a) {
cout << "Ping";
}
else {
cout << "Cong";
}
}
int main() {
int m, x, y;
int a, b; // 甲、乙
double c=-1; // 丙
cin >> m >> x >> y;
for (int i=10; i<100; i++) {
int aa=i;
int bb=invert(aa);
if (bb*1.0/y == abs(aa-bb)*1.0/x) {
a = aa;
b = bb;
c = bb*1.0/y;
}
}
if (c == -1) {
cout << "No Solution" << endl;
}
else {
cout << a << " ";
compare(m, a);
cout << " ";
compare(m, b);
cout << " ";
compare(m, c);
cout << endl;
}
return 0;
}