# 【题解】Cards For Friends 【水题】

A. Cards for Friends

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

For the New Year, Polycarp decided to send postcards to all his nn friends. He wants to make postcards with his own hands. For this purpose, he has a sheet of paper of size w×hw×h, which can be cut into pieces.

Polycarp can cut any sheet of paper w×hw×h that he has in only two cases:

• If ww is even, then he can cut the sheet in half and get two sheets of size w/2×h
• If hh is even, then he can cut the sheet in half and get two sheets of size w×h/2

If ww and hh are even at the same time, then Polycarp can cut the sheet according to any of the rules above.

After cutting a sheet of paper, the total number of sheets of paper is increased by 1

Help Polycarp to find out if he can cut his sheet of size w×hw×h at into nn or more pieces, using only the rules described above.

Input

The first line contains one integer tt (1≤t≤1e4) — the number of test cases. Then tt test cases follow.

Each test case consists of one line containing three integers w, h, n (1≤w,h≤1e4, 1≤n≤1e9) — the width and height of the sheet Polycarp has and the number of friends he needs to send a postcard to.

Output

For each test case, output on a separate line:

• "YES", if it is possible to cut a sheet of size w×hw×h into at least nn pieces;
• "NO" otherwise.

You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).

一张w×h的纸，如果w为偶数（或h为偶数），那么就可以把这张纸裁成两张w/2 × h（或w × h/2）的纸。已知一张纸的w和h，求最多能裁出多少张纸。

显然，按照w裁剪或按照h裁剪的先后顺序对最终结果没有影响，因此，只需统计w和h中因子2的个数即可。

```#include <bits/stdc++.h>

int t;

int num;

int w,h,n;

int main(){

scanf("%d",&t);

while(t--){

scanf("%d%d%d",&w,&h,&n);

num= 1;

for(int i = 2;w % i == 0 ;i *= 2){

num *= 2;

}

for(int i = 2;h % i == 0 ;i *= 2){

num *= 2;

}

if(num<n)printf("NO\n");

else printf("YES\n");

}

return 0;

}```

【题解】Cards For Friends 【水题】

(0)
(0)