Http://acm.uestc.edu.cn/problem.php? Pid = 1784 & amp; Description time is the most elusive thing. it is hard to measure them. Generally, the measurement time defines the minimum measurable unit of time with an event that can be repeated and so on. So Kr http://acm.uestc.edu.cn/problem.php? Pid = 1784 &&
Description
Time is the most elusive thing. it is very difficult to measure them. Generally, the measurement time defines the minimum measurable unit of time with an event that can be repeated and so on. So Krolia came up with a good way to measure time.
Krolia has a match. if the match head is removed, it will become a long wooden stick. Krolia knows that after one end of a wooden stick is ignited, the entire burning will last for x time. Krolia can also ignite a wooden stick from both ends at the same time, so that the burning will continue for x/2 time. Now Krolia wants to use these matches for timing and asks what time can be fully and accurately calculated.
Input
The first line is an integer T (T <= 1000), indicating that there are T groups of test data. The three integers a, B, x (1 <=, b, x <= 10 ^ 9) indicates to measure a/B. the burning duration of a match is x time.
Output
A string. "YES" or "NO" indicates that it can or cannot be accurately calculated.
Sample Input
4
1 1 1
1 2 1
1 4 1
1 5 1
Sample Output
YES
YES
YES
NO
Hint
Burn a wooden stick from the endpoint.
Ignition a wooden stick from both ends.
Ignition of a wooden stick from both ends, and ignition of a wooden stick from the endpoint. When the first wooden stick is exhausted, the fire of the remaining wooden stick is extinguished. Finally, the two ends of the remaining wooden sticks are ignited at the same time.
I found a regular question for a long time during the competition yesterday afternoon ~
Question: Here are two numbers x and x/2. if x is an even number, you can convert it to an odd number, then find the law in which x is an odd number: molecular a must be able to divide x, and B must be able to convert to the power of two.
AC code:
#include
#include
#include#include
#define CLR(arr,val) memset(arr,val,sizeof(arr))using namespace std;int gcd(int a,int b){ while(b) { int temp=a%b; a=b; b=temp; } return a;}void in(int &a){ char ch; while((ch=getchar())<'0'||ch>'9'); for( a=0;ch>='0'&&ch<='9';ch=getchar()) a=a*10+ch-'0';}int main(){ int n; while(~scanf("%d",&n)) { for(int i=0;i!=n;++i) { int a,b,x; in(a),in(b),in(x); int ans=gcd(a,b); a=a/ans; b=b/ans; while(x%2==0) x/=2; int k=b; if(a%x==0){ while(k%2==0) k/=2; if(k==1) puts("YES"); else puts("NO"); } else puts("NO"); } } return 0;}