zoukankan      html  css  js  c++  java
  • UVA 696 How Many Knights

    真心没发现规律。感觉挺像CF一些锻炼思维的题

    看了这里http://hi.baidu.com/knowledgetime/item/87d13b1f12290a53f1090ea7

    #include <map>
    #include <set>
    #include <list>
    #include <cmath>
    #include <ctime>
    #include <deque>
    #include <stack>
    #include <queue>
    #include <cctype>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <climits>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #define LL long long
    #define PI 3.1415926535897932626
    using namespace std;
    int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
    int N,M;
    int slove()
    {
        if (N == 1 || M == 1)  return max(N,M);
        else if (N == 2 || M == 2)
        {
            if (M > N) swap(N,M);// N>M;right now M == 2;
            int cnt = N / 4 * 4;
            if (N % 4 == 1 || N % 4 == 2 ) cnt += N % 4 * 2;
            else if (N % 4 == 3) cnt += 4;
            return cnt;
        }
        else return ((M * N) + 1) / 2;
    }
    int main()
    {
        while (scanf("%d%d",&N,&M)!=EOF)
        {
            if (N == 0 && M == 0) break;
            int u = N , v = M;
            printf("%d knights may be placed on a %d row %d column board.
    ",slove(),u,v);
        }
        return 0;
    }
  • 相关阅读:
    Day 43
    Day 42
    Day 41
    Day 40
    Linux下查看服务器的产品型号和序列号
    AgileController Portal认证成功后弹出找不到指定位置的资源
    华三交换机snmp开通
    FusionCompute 6.3.0 CNA系统安装
    集群IMC策略
    静态路由配置语法
  • 原文地址:https://www.cnblogs.com/Commence/p/3993962.html
Copyright © 2011-2022 走看看