• 2016-2017 ACM-ICPC, NEERC, Central Subregional Contest C


    Desktop

    题意:有一个大小为n*m的桌面(由右下角从0开始的网格),每个图标的大小为2*2,每个图标最少要露出一半才能正常使用,求最多可以放下多少图标,并且按任意一种摆放的顺序输出每个图标右上角的坐标,后面摆放的图标只能覆盖原来的

    思路:最后只有一个图标是露出4个格子,其他全部露出2个,若n,m都是奇数,那么有一个格子是空开的,ans=(n-4>>1)+1,坐标xjb模拟就是了

    AC代码:

    #include "iostream"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #define ll long long
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a) memset(a,0,sizeof(a))
    #define mp(x,y) make_pair(x,y)
    #define pb push_back
    using namespace std;
    const int N=1e5+100;
    int n,m;
    struct Node{
        int l,c;
        Node(int lx, int cx){
            l=lx,c=cx;
        }
    };
    vector<Node> vex;
    int main(){
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        //scanf("%d %d",&n,&m);
        cin>>n>>m;
        if(n<=1 || m<=1){
            cout<<0<<endl;
            return 0;
        }
        cout<<(n*m-4>>1)+1<<endl;
        if(m&1){
            for(int i=1; i<n-2; i+=2){
                //printf("%d %d
    ",i,m-1);
                cout<<i<<" "<<m-1<<endl;
                //Node now(i,m-1);
                //vex.pb(now);
            }
        }
        for(int i=1; i<m; i+=2){
            for(int j=1; j<n-1; ++j){
                //printf("%d %d
    ",j,i);
                cout<<j<<" "<<i<<endl;
                //Node now(j,i);
                //vex.pb(now);
            }
        }
        for(int i=1; i<m; ++i){
            //printf("%d %d
    ",n-1,i);
            cout<<n-1<<" "<<i<<endl;
            //Node now(n-1,i);
            //vex.pb(now);
        }
        //for(auto j :vex){
            //cout<<j.l<<" "<<j.c<<endl;
        //}
        return 0;
    }
  • 相关阅读:
    Sql中使用With创建多张临时表
    sql(join on 和where的执行顺序)
    什么是正则化
    ETL讲解(转)
    MySQL等 SQL语句在线练习
    Sublime text 3 --html
    Sublime text 3 搭建Python3 IDE
    地区列车经过查询
    Lasso回归算法: 坐标轴下降法与最小角回归法小结
    完全卸载VMware
  • 原文地址:https://www.cnblogs.com/max88888888/p/7161570.html
Copyright © 2020-2023  润新知