cf593div2

https://codeforces.com/contest/1236/problem/A

#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    int t,a,b,c;
    cin >> t;
    while(t--) {
        cin >> a>> b>>c;
        int x = c/2, sum = 0;
        sum += 3*min(x, b);
        b -= min(x,b);
        int y = b/2;
        sum += min(a, y) *3;
        cout << sum << endl;
    }
    return 0;
}

https://codeforces.com/contest/1236/problem/B

First, we can think about putting one present in m boxs, each box has two conditions(put or not) ,so the res is 2^m, and we should subtract 1(all boxs are empty).(the answer one present in m boxs is 2^m-1)

Then we have n presents, so the amnswer is (2^m-1)^n,

#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll mod = 1e9+7;
ll fpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b & 1) ret = ret*a%mod;
        a = a*a%mod;
        b >>= 1;
    }
    return ret;
}
int main(){
    int t;
    t = 1; //cin >> t;
    while(t--) {
        ll a,b;
        cin >> a >> b;
        if(b == 1) cout << "1
";
        
        else cout << fpow(fpow(2, b)-1, a) << endl;
       
    }
    return 0;
}

https://codeforces.com/contest/1236/problem/C

The maximum number is floor(n2/2)  具体证明不会 emmmmmmmm
可以蛇形填数(如下)
 1 6 7
 2 5 8
 3 4 9

#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define _for(i,a,b) for(int i = (a); i < (b); i++)
#define _rep(i,a,b) for(int i = (a); i <= (b); i++)
const ll mod = 1e9+7;
 
int main(){
    int t,a,b,c;
    t = 1; //cin >> t;
    while(t--) {
        int dp[303][303];
        cin >> a;
        _rep(j,1,a)
            {
                if(j&1) _for(i,0,a) dp[i][j] = 1+(j-1)*a+i;
                else    _for(i,0,a) dp[i][j] = j*a-i;
            }
        
        _rep(i,0,a-1) _for(j,1,a+1)
             cout << dp[i][j] <<(j==a?"
":" ");
    }
    return 0;
}
/*
2 8 5
9 3 4
7 6 1
*/

https://codeforces.com/contest/1236/problem/D

//直接模拟这个过程, 用两个vector存下 每行的障碍列数 和 每列的的障碍行数
//从左到右 -> 从上到下 -> 从右到左 -> 从下到上 (用四个变量为上下左右的边界 当无路可走时 结束模拟)
//记录能走的步数, 最后结束时 判断下 是否能走的步数为 n*m-k 若能則輸出 Yes 否則 No

#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
 
using namespace std;
#define ll long long
#define _for(i,a,b) for(int i = (a); i < (b); i++)
#define _rep(i,a,b) for(int i = (a); i <= (b); i++)
const int N = 1e5+10;
vector<int> row[N], col[N];
 
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int n,m,k; cin >> n >> m >> k;
    _for(i,0,k) {
        int x,y;
        cin >> x>>y;
        row[x].push_back(y); col[y].push_back(x);
    } 
    _for(i,0,N-5) sort(row[i].begin(), row[i].end());
    _for(i,0,N-5) sort(col[i].begin(), col[i].end());
    int to, lb = 1, ub = 2, rb = m, db = n, x = 1, y = 1;ll ans = 1;
    while(1) {
        to = rb;
        _for(i,0,row[x].size()) {//从左到右
            if(row[x][i] > y && row[x][i]-1 < rb)
                {to = row[x][i]-1; break;}
        }
        if((!(x==1&&y==1)) && to<=y) break;
        ans += to-y;
        rb = to-1; y = to;
//cout << "1	" << ans << endl;
        to = db;
        _for(i,0,col[y].size()){//从上到下
            if(col[y][i] > x && col[y][i]-1 < db)
                {to = col[y][i]-1; break;}
        }
        if(to <= x) break;
        ans += to-x; 
        db = to-1; x = to;
//cout << "2	" << ans << endl;
        to = lb;
        for(int i = row[x].size()-1; i >= 0; i--)
        {//从右到左
            if(row[x][i] < y && row[x][i]+1 > lb)
                {to = row[x][i]+1; break;}
        }
        if(to >= y) break;
        ans += y-to;
        lb = to+1; y = to;
//cout << "3	" << ans << endl;
        to = ub;
        for(int i = col[y].size()-1; i >= 0; i--)
        {//从下到上
            if(col[y][i] < x && col[y][i]+1 > ub)
                {to = col[y][i]+1; break;}
        }
        if(to >= x) break;
        ans += x-to;
        ub = to+1; x = to;
//cout << "4	" << ans << endl;
    }
    puts(ans+k == 1ll*n*m?"Yes":"No");
    return 0;
}

https://codeforces.com/contest/1236/problem/E

  1.  
原文地址:https://www.cnblogs.com/163467wyj/p/11714261.html