• CCF--201912-2 回收站选址


    
    
    #include<iostream>
    using namespace std;
    
    struct node{
        int x;
        int y;
        int flag = 0;
        int score = 0;
    }node;
    
    
    int main(){
        int n;
        cin >> n;
        struct node arr[n];
        int scores[5] = {0,0,0,0,0};
        for(int i = 0; i < n; i++){
            cin >> arr[i].x >> arr[i].y;
        }
        int x0, y0;
        //check
        for(int i = 0; i < n; i++){
            x0 = arr[i].x;
            y0 = arr[i].y;
            for(int j = 0; j < n; j++){
                if(x0 == arr[j].x && (y0+1) == arr[j].y){
                    arr[i].flag ++;
                }
                if(x0 == arr[j].x && (y0-1) == arr[j].y){
                    arr[i].flag ++;
                }
                if((x0+1) == arr[j].x && y0 == arr[j].y){
                    arr[i].flag ++;
                }
                if((x0-1) == arr[j].x && y0 == arr[j].y){
                    arr[i].flag ++;
                }
    
                if((x0+1) == arr[j].x && (y0+1) == arr[j].y){
                    arr[i].score ++;
                }
                if((x0-1) == arr[j].x && (y0-1) == arr[j].y){
                    arr[i].score ++;
                }
                if((x0+1) == arr[j].x && (y0-1) == arr[j].y){
                    arr[i].score ++;
                }
                if((x0-1) == arr[j].x && (y0+1) == arr[j].y){
                    arr[i].score ++;
                }
            }
            if(arr[i].flag == 4){
                scores[arr[i].score] ++;
            }
    
        }
    
    
        for(int i = 0; i < 5; i++){
            cout << scores[i] << endl;
        }
    
    
    
    }
    
    

    害,打几个循环就能出来的事,我当初却只有0分,真是太drama了

  • 相关阅读:
    剩余类&完全剩余组
    同余验算法
    一种快速余数求法
    同余的性质II
    同余初步
    求N个数的最小公倍数
    N个数GCD求解法
    快速求解GCD的三个Trick
    质数的几个有趣问题
    等比数列求和公式
  • 原文地址:https://www.cnblogs.com/yuyuan-bb/p/13638383.html
Copyright © 2020-2023  润新知