13th ACM session L-the potion used for cheating, acml-
Time Limit: C/C ++ 1 second, 2 seconds for other languages
Space limit: C/C ++ 32768 K, other languages 65536 K
64bit IO Format: % lld topic description on A stormy night, TMK students from different worlds who do not want to be named have two super potion A and B. According to the instruction, TMK understands the functions of these two potions:
(1) potion A can increase the person's life, and each unit consumed can change his life to x times of the original life, that is to say, every consumption of p units can change his life value to the original x ^ p (p power of x) times.
(2) potion B can increase the energy value of a person. Each drinking unit can change his energy value to y times of the original one, that is, the unit of q consumed can change the energy value to the power of y ^ q (q power of y.
So TMK couldn't wait to drink all the potion a and B in unit A. He immediately realized the strong changes in his ability and then read the following instructions:
Both potion A and potion B can suppress the negative effects of each other. Once the multiples of the life value increase and the multiples of the same value increase, in five hours, serious consequences will occur.
As a result, TMK was panic. He wanted to know whether the upgraded life value and the multiples of the energy value were equal. As he was very flustered, he handed over the computing task to you.
As a member of Accenture, you think this problem is very simple, thanks to the culture in which Accenture shares its knowledge.
Sharing knowledge has become a long-standing culture of Accenture.
While helping customers implement effective knowledge management, Accenture's management also implements successful knowledge management practices internally. Today, sharing knowledge in Accenture has become a long-standing culture. To a large extent, Accenture's success has benefited from its powerful knowledge management system.
Input description:
The first line is an integer T, which indicates that there are T groups of data. (1 <= T <= 5000) each group of data contains only one row, which contains four integers x, a, y, and B. It indicates the topic description. (1 <= x, a, y, B <= 10 ^ 9)
Output description:
Output a row of "Yes" or "No" (double quotation marks excluded) for each group of data, indicating whether the upgraded TMK's life value and the multiples of the energy value are equal, equal to "Yes ", not equal to "No ".
Example 1 Input
42 20 4 1020 20 20 2020 21 21 2032768 32768 1048576 24576
Output
YesYesNoYes
It's a mathematical knowledge. I don't know at all. I can use the log function directly in C ++. Now I have learned that to determine whether the floating point number is equal, we need to determine whether the difference is smaller than a decimal number, because there is a very small error after the floating point.
1 #include <cstdio> 2 #include <iostream> 3 #include <algorithm> 4 #include <cmath> 5 using namespace std; 6 7 int main() 8 { 9 int T; 10 double x,a,y,b; 11 scanf("%d",&T); 12 while(T--) 13 { 14 scanf("%lf%lf%lf%lf",&x,&a,&y,&b); 15 if(fabs(a * log10(x) - b * log10(y)) < 1e-6) 16 { 17 printf("Yes\n"); 18 } 19 else 20 { 21 printf("No\n"); 22 } 23 } 24 25 return 0; 26 27 }
13:40:31