这道题本身不难,但有一个很容易被坑的地方:
丙的值未必是整数!!!
丙的值未必是整数!!!
丙的值未必是整数!!!
还有一个tips:
输出时行首位不得有多余空格,这话可能会没注意到导致大部分的格式错误,不过这个很容易发现,上面那个不是整数要用浮点是真的坑。
using namespace std;
#include<bits/stdc++.h>
void cmp(double t,int m){
if(t>m) cout<<"Cong";
else if(t == m) cout<<"Ping";
else cout<<"Gai";
}
int main(){
int m,x,y;
double a,b,c;
cin>>m>>x>>y;
int i;
for(i=99;i>=10;i--)
{
a=i;
int tmp1=a/10,tmp2=(int)a%10;
b=tmp2*10+tmp1;
int dis;
if(a>b) dis=a-b;
else dis=b-a;
double t1,t2;
t1=dis*1.0/x;
t2=b*1.0/y;
if(t1 == t2)
{
c=t1;
break;
}
}
if(i>=10)
{
cout<<a<<" ";
cmp(a,m);
cout<<" ";
cmp(b,m);
cout<<" ";
cmp(c,m);
}
else
{
cout<<"No Solution\n";
}
}