zoukankan      html  css  js  c++  java
  • UVaLive 6858 Frame (水题)

    题意:给定一个矩形框架,给定一个小矩形,问你能不能正好拼起来。

    析:很简单么,就三种情况,如果是1*1的矩形,或者是1*2的一定可以,然后就是上面和下面正好能是小矩形的整数倍,左右是少一,两个就是整数倍。

    最后一种是,每一边都减1,是小矩形的整数倍。

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    #include <stack>
    using namespace std ;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int maxn = 1e5 + 5;
    const int mod = 1e9 + 7;
    const char *mark = "+-*";
    const int dr[] = {-1, 0, 1, 0};
    const int dc[] = {0, 1, 0, -1};
    int n, m;
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    
    bool solve(int x){
        if(1 == x || 2 == x)  return true;
        if(n % x == 0 && m % x == 2)  return true;
        if(m % x == 0 && n % x == 2)  return true;
        if(m % x == 1 && n % x == 1)  return true;
        return false;
    }
    
    int main(){
        while(scanf("%d %d", &n, &m) == 2){
            int q, x;
            scanf("%d", &q);
            while(q--){
                scanf("%d", &x);
                if(solve(x))   puts("YES");
                else  puts("NO");
            }
        }
        return 0;
    }
    

      

  • 相关阅读:
    NOIP2020 游记
    李超线段树
    选举「elections」
    Alt+数字输入
    素数
    CSP-S2020 爆炸记
    [CF487C] Prefix Product Sequence
    [CF489E] Hiking
    L2-019 悄悄关注 (25 分)
    L2-032 彩虹瓶 (25 分)
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5781506.html
Copyright © 2011-2022 走看看