PAT_B_1088_ threesome

Subject description:

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

The title given value relationships A, B, C three people capacity: the ability to determine the value of A 2 is a positive integer; ability value of the two digital positions exchange ability value of a is b; X and b is two times the poor ability value of the prop; ability value Y b is the propionate times. Please point out who is stronger than you should, "from the" weak who should "corrections" than you. 

Input format: 
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 Format: 
First, the ability value output in line A, and then sequentially outputs A, B, C and three of your relationship: if it is better than you, Cong output; the Ping equal output; 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, the output No Solution. 

Input Example 1: 
4837 
Output Sample 1: 
48 the Ping Cong Gai 
Input Sample 2: 
48 116 
Output Sample 2: 
No Solution

Finishing ideas:

A reverse traversal (99-10), the first to find a solution in line with requirements of the subject 
propylene is not necessarily an integer type is set to double

I AC Code:

// three rows 1088 
# the include <stdio.h> 
# the include <math.h> 
// output their numerical relationship with ABC 
void Print (int, Double); 

int main (void) 
{ 
	int M, A, B; respectively, and their // AB 
	double C; // propan not be an integer 
	int X-, the Y; 
	int in flag = 0; // flag absence Solutions 
	scanf ( "% d% d% d", & M, & X, the Y &); 
	
	for (a = 99; a> = 10; A--) 
	{ 
		// a calculated value B B 
        B = (a% 10) + a * 10/10; 
       	C = ABS (AB) * 1.0 / X- ; 
        IF (the Y B == C *) 
		{ 
            In Flag =. 1; 
            BREAK; 
        } 
    } 
	// if a solution, in accordance with the rules of the output 
	IF (In Flag ==. 1) 
	{ 
		the printf ( "% D", A);  
		Print (M , A);
		Print (M , B);
		print(M,C);
	 } 
	 // 否则输出无解
	 else
	 {
	 	printf("No Solution\n");
	  } 
	
	return 0;
 }
  
void print(int M, double N) 
{
    if (M == N) 
		printf(" Ping");
    else if (M < N) 
		printf(" Cong");
    else 
		printf(" Gai");
}

  

RRR

Guess you like

Origin www.cnblogs.com/Robin5/p/11210352.html