2019年我能变强组队训练赛第八场

#include <bits/stdc++.h>
  
using namespace std;
int f[4][4][205][205],hi;
int main() {
    f[0][0][0][0] = 1;
    for (int i = 0; i <= 3; i++)
        for (int j = 0; j <= 3; j++) {
            if (max(i, j) >= 3) continue;
            if (i + j == 4) hi = 15; else hi = 25;
            for (int k = 0; k <= 200; k++)
                for (int l = 0; l <= 200; l++) {
                    if (!f[i][j][k][l]) continue;
                    for (int kk = hi; kk <= 200; kk++) {
                        if (k + kk - 2 <= 200 && l + kk <= 200 && f[i][j + 1][k + kk - 2][l + kk] == 0)
                            f[i][j + 1][k + kk - 2][l + kk] = 1;
                        if (k + kk <= 200 && l + kk - 2 <= 200 && f[i + 1][j][k + kk][l + kk - 2] == 0)
                            f[i + 1][j][k + kk][l + kk - 2] = 1;
                    }
                    for (int kk = 0; kk <= hi - 2; kk++) {
                        if (k + kk <= 200 && l + hi <= 200 && f[i][j + 1][k + kk][l + hi] == 0)
                            f[i][j + 1][k + kk][l + hi] = 1;
                        if (k + hi <= 200 && l + kk <= 200 && f[i + 1][j][k + hi][l + kk] == 0)
                            f[i + 1][j][k + hi][l + kk] = 1;
                    }
                }
        }
    int _, ans1, ans2;
    scanf("%d", &_);
    while (_--) {
        int a, b;
        scanf("%d%d", &a, &b);
        ans1 = ans2 = 0;
        if (f[3][0][a][b]) {
            ans1 = 3;
            ans2 = 0;
        }else
        if (f[3][1][a][b]) {
            ans1 = 3;
            ans2 = 1;
        }else
        if (f[3][2][a][b]) {
            ans1 = 3;
            ans2 = 2;
        }else
        if (f[2][3][a][b]) {
            ans1 = 2;
            ans2 = 3;
        }else
        if (f[1][3][a][b]) {
            ans1 = 1;
            ans2 = 3;
        }else
        if (f[0][3][a][b]) {
            ans1 = 0;
            ans2 = 3;
        }
        if (ans1 == 0 && ans2 == 0) printf("Impossible\n"); else printf("%d:%d\n", ans1, ans2);
    }
}

#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
ll n;
 
int main() {
 
    ll cnt = 0;
    ll f = 0;
    scanf("%lld", &n);
    ll x = n;
    for (ll i = 2; i <= sqrt(n); ++i) {
 
        if (x % i == 0) {
            cnt++;
            while (x % i == 0) {
                x /= i;
            }
        }
    }
    if (x > 1)
        cnt++;
    if (cnt >= 2)
        f = 1;
    if (f) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
 
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int a[1000],k,cnt,ans,kk;
int main() {
    int _;
    scanf("%d", &_);
    while (_--) {
        scanf("%d", &k);
        cnt = 0;
        for (int i = 1; i <= 7; i++) {
            scanf("%d", &a[i]);
            a[i + 7] = a[i];
            if (a[i]) cnt++;
        }
        ans = inf;
        for (int i = 1; i <= 7; i++) {
            kk = k;
            for (int j = i; j <= i + 7; j++) {
                kk -= a[j];
                if (kk % cnt == 0)
                    ans = min(ans, j - i + 1 + kk / cnt * 7);
            }
        }
        printf("%d\n", ans);
    }
}

#include <bits/stdc++.h>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
struct node{
    int a;
    ll b;
    bool operator<(const node& s)const {
        return b<s.b;
        //return a<s.a;
    }
}c[maxn];
int n,k;
int vis[maxn];
ll res;
 
int main() {
    //freopen("1.txt", "r", stdin);
    scanf("%d%d",&n,&k);
    for(register int i=1;i<=n;++i){
        scanf("%d",&c[i].a);
        vis[c[i].a]++;
    }
    for(register int i=1;i<=n;++i){
        scanf("%lld",&c[i].b);
    }
    sort(c+1,c+1+n);
    int cnt=0;
    for(register int i=1;i<=k;++i){
        if(!vis[i]){
           ++cnt;
        }
    }
    //cout<<cnt<<endl;
    for(int i=1;i<=n;++i){
        //cout<<c[i].b<<endl;
        if(vis[c[i].a]>1&&cnt){
            //printf("%d %d %d\n",i,vis[i],c[i].b);
            --vis[c[i].a];
            --cnt;
            res+=c[i].b;
        }
    }
    printf("%lld\n",res);
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/Accpted/p/11407790.html