Namomo Winter Camp D3 Div2 简易题解

Problem K. Kotlin Island

首先不用考虑描边(那样和不画这条边是一样的)。那么剩下的就是在长度和宽度内枚举了。显然可以知道长宽最多画 \((n - 1) / 2\)\((m - 1) / 2\) 条线。

#include <bits/stdc++.h>
using namespace std;

int n, m, k; 

char a[500][500]; 

int main(){
    freopen("kotlin.in", "r", stdin);
    freopen("kotlin.out", "w", stdout); 
    cin >> n >> m >> k; 
    int l1 = (n - 1) / 2; 
    int l2 = (m - 1) / 2; 
    if(k > (l1 + 1) * (l2 + 1)){
        puts("Impossible");
        return 0;
    }

    int x1, x2; 
    bool flag = 0; 
    for(int i = 1; i <= l1 + 1; i++){
        if(k % i == 0){
            int j = k / i; 
            if(j >= 1 && j <= l2 + 1){
                flag = 1; 
                x1 = i, x2 = j; 
                break; 
            }
        }
    }
    if(!flag){
        puts("Impossible"); 
    }
    else{
        int num = 0; 
        for(int i = 2; i <= n; i += 2){
            if(num == x1 - 1) break; 
            for(int j = 1; j <= m; j++){
                a[i][j] = '#'; 
            }
            num++; 
            
        }
        num = 0; 
        for(int j = 2; j <= m; j += 2){
            if(num == x2 - 1) break;
            for(int i = 1; i <= n; i++) 
                a[i][j]= '#'; 
            num++; 
             
        }
        for(int i = 1; i <= n; i++, puts("")){
            for(int j = 1; j <= m; j++){
                if(a[i][j] != '#') printf("."); 
                else printf("#"); 
            }
        }
    }
    return 0; 
}

Problem A. Auxiliary Project

可以知道拿 \(7\) 是最赚的。在拿 \(7\) 会导致无法消耗完剩下的木棍时(余\(1\))时,不拿 \(7\) 而是一次性拿完剩下的能拿的最大的即可。

#include <bits/stdc++.h>
using namespace std;
#define N 100010

vector <int> G[N]; 

int main(){
    freopen("auxiliary.in", "r", stdin); 
    freopen("auxiliary.out", "w", stdout); 
    G[2].push_back(1); 
    G[3].push_back(7); 
    G[4].push_back(4); 
    G[5].push_back(2); 
    G[5].push_back(3); 
    G[5].push_back(5); 
    G[6].push_back(6); 
    G[6].push_back(9); 
    G[6].push_back(0); 
    G[7].push_back(8); 

    for(int i = 2; i <= 7; i++){
        sort(G[i].begin(), G[i].end(), [](int a, int b) -> bool {return a > b; });
    }
    
        int n; cin >> n; 
        int ans = 0; 
        while(n - 3 >= 2){
            n -= 3; 
            ans += 7; 
        }
        ans += G[n][0]; 
        cout << ans << endl; 
    

}
posted @ 2023-01-09 23:26  雪之下,树之旁  阅读(46)  评论(0编辑  收藏  举报