注意:我的能力值、丙的能力值可能是double 型,而甲、乙的能力值是 int型,比较的大小的时候要使用double,不然测试点4过不去。
#include<iostream> #include<algorithm> using namespace std; void print(double a,double b) { if(a > b) printf(" Cong"); else if(a == b) printf(" Ping"); else printf(" Gai"); } int main() { double m,bing; int x,y,jia,yi; cin>>m>>x>>y; for(jia = 99; jia >= 10; --jia){ yi = (jia%10)*10+jia/10; if(abs(jia-yi)*y == x*yi) { bing = yi*1.0/y; break; } } if(jia < 10) cout<<"No Solution"; else { printf("%d",jia); print(jia,m); print(yi,m); print(bing,m); } return 0; }
来源:https://www.cnblogs.com/keep23456/p/12366426.html