• UVA 1605 Building for UN (联合国大楼)


    题意:一个联合国大楼每层都有数量相等大小相同的格子,将其分配给n个国家,使任意两个不同的国家都相邻(同层有公共边或相邻层的同一个格子)。

    分析:可以设计一个只有两层的大楼,第一层每个国家占一行,第二层每个国家占一列,即每层都是n*n的。

    #pragma comment(linker, "/STACK:102400000, 102400000")
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define Min(a, b) ((a < b) ? a : b)
    #define Max(a, b) ((a < b) ? b : a)
    typedef long long ll;
    typedef unsigned long long llu;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
    const ll LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const double eps = 1e-8;
    const int MAXN = 10000 + 10;
    const int MAXT = 10000 + 10;
    using namespace std;
    map<int, char> mp;
    void init(){
        string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        for(int i = 0; i < 52; ++i){
            mp[i] = s[i];
        }
    }
    int main(){
        int n;
        init();
        bool flag = true;
        while(scanf("%d", &n) == 1){
            if(flag) flag = false;
            else printf("\n");
            printf("2 %d %d\n", n, n);
            for(int i = 0; i < n; ++i){
                for(int j = 0; j < n; ++j){
                    printf("%c", mp[i]);
                }
                printf("\n");
            }
            printf("\n");
            for(int i = 0; i < n; ++i){
                for(int j = 0; j < n; ++j){
                    printf("%c", mp[j]);
                }
                printf("\n");
            }
        }
        return 0;
    }
  • 相关阅读:
    LeetCode Notes_#20 Valid Parentheses
    LeetCode Notes_#14 Longest Common Prefix
    牛客21天刷题_day#3
    牛客21天刷题_day#2
    牛客21天刷题_day#1
    WebGL编程指南
    《Redis 设计与实现》
    《女士品茶》
    《Java应用架构设计:模块化模式与OSGi》
    《编译与反编译技术实战》
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/6323555.html
Copyright © 2020-2023  润新知