Codeforces Round #693 (Div. 3) A. Cards for Friends

点击题目可传送至题面

A. Cards for Friends

题意分析

一道简单的水题, 让输入的两个偶数不断除2,直到变成奇数位置,同时统计除的次数,最后再和人数比较输出结果。这道题虽然水,但是怎样用最快最简便的方法写出是值得我们思考的

#include<iostream>
using namespace std;
int T;
int main(){
    ios_base::sync_with_stdio(false), ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> T;
    while(T--){
        int w, h, n;
        long long ans = 1; // 因为是从一张纸开始分割的,所以ans应该从1开始
        cin >> w >> h >> n;
        while(w % 2 == 0) ans *= 2, w /= 2;      
        while(h % 2 == 0) ans *= 2, h /= 2;
        
        if(ans >= n) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    
    return 0;
}
原文地址:https://www.cnblogs.com/FrankOu/p/14235229.html