1088 three rows (20 points)

Confucius said: "three-line, must be my teacher choosing the good from it, their bad corrections.."

Ability value relationship The title given A, B, C three of: determining the capacity value of A is 2 positive integer; the two digital exchange places the ability value of A is the ability value acetate; and B both poor is X times the capacity value of the prop; b ability value is prop-Y of times. Please point out who is stronger than you should, "from the" weak who should "corrections" than you.

Input formats:

Enter the number of three in a row are given, followed by: M (your own ability value), X and Y. No more than three numbers are positive integers 1000.

Output formats:

First, the ability value output line A, and then sequentially outputs A, B, propoxy relationship with your three: if it is better than you output  Cong; equality output  Ping; the output is weaker than you  Gai. Meanwhile separated by a space, the line from beginning to end may not have the extra space.

Note: If the solution is not unique, the maximal solution places A subject judged; if the solution does not exist, then the output  No Solution.

Sample Input 1:

48 3 7

Output Sample 1:

48 Ping Cong Gai

Sample Input 2:

48 11 6

Output Sample 2:

No Solution
#include<iostream>
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
	int m,x,y,first,second;
	double third; // 测试点4的坑,只是m,x,y三个是正整数。甲也是2位数的正整数,但没说丙是int类型。 
	cin>>m>>x>>y;
	for(first=99;first>9;first--){
		second = 10*(first%10) + first/10;
		if(y*abs(second-first) == x*second){
			third = second*1.0/y;
			printf("%d %s %s %s",first,m==first?"Ping":m>first?"Gai":"Cong", m==second?"Ping":m>second?"Gai":"Cong", m==third?"Ping":m>third?"Gai":"Cong");
			return 0;
		}
	}
	printf("No Solution");
	return 0;
}

 

Published 67 original articles · won praise 14 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_38603360/article/details/103706001