牛客2022跨年场

B.分赃

首先统计只有一个的数字个数,如果是偶数就平均分给两个人,然后把剩下的数字全部分给任意一个人。

如果是奇数个,就看时候有数字的数量大于三,如果有,就把这个数字的其中一个分给少的人,然后把剩下所有的数字分给另一个人。

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

int read(){
    int x = 0 , f = 1 , ch = getchar();
    while( (ch < '0' || ch > '9') && ch != '-' ) ch = getchar();
    if( ch == '-' ) f = -1 , ch = getchar();
    while( ch >= '0' && ch <= '9' ) x = ( x << 3 ) + ( x << 1 ) + ch - '0' , ch = getchar();
    return x * f;
}

int main(){
    int n = read();
    map<int,int> mp;
    for( int i = 1 , x ; i <= n ; i ++ )
        x = read() , mp[x] ++;
    int a = 0 , b = 0;
    for( auto [ k , v ] : mp ){
        if( v == 1 ) a ++;
        else if( v >= 3 ) b ++;
    }
    if( a % 2 == 0 ){
        cout << "YES";
        return 0;
    }
    if( b > 0 ){
        cout << "YES\n";
        return 0;
    }
    return 0;
}

F.回顾往昔

签到

print("【2021跨年赛讲题】兰子哥哥一万粉女装")
print("2022-01-01 00:20:50")
print("BV1ga411z7PM")

G.李哥跨年

签到

print("6")

A.猜群名(补题)

print("EGHDBCFA")

C.翻卡牌(补题)

把一个九位数复制一遍等价于乘\(10^9+1\)\(10^9+1 \mod 7 = 0\)所以答案恒等于0

print("0")

D.ygg的分数运算(补题)

无论是乘法还是加法,操作后分母都是\(a\times b\),所以分母最终的结果一定是\(a^{k_1}\times b^{k_2}\)这样的数,所以判断\(c\)\(a,b\)除尽后的结果即可

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

int main(){
    int a , b , c;
    cin >> a >> b >> c;
    while( c % a == 0 ) c /= a;
    while( c % b == 0 ) c /= b;
    if( c == 1 ) cout << "YES\n";
    else cout << "NO\n";
}

E.摇色子(补题)

娱乐题

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

int main(){
    int n ; cin >> n;
    mt19937 rd( 37 * 6 + n );
    cout << 1 << " " << rd() % 2 + 1 << "\n";
    return 0;
}

H.nana吃蛋糕(补题)

每一次移动会导致\(x+y\)的奇偶性发生改变,如果\(n\)是偶数的话,一定要至少舍弃一个点,并且因为\(1+1\)\(n+n\)都是偶数所以舍弃的一定是一个\(x+y\)为奇数的点,所以舍弃权值最小的点即可

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

int read(){
    int x = 0 , f = 1 , ch = getchar();
    while( (ch < '0' || ch > '9') && ch != '-' ) ch = getchar();
    if( ch == '-' ) f = -1 , ch = getchar();
    while( ch >= '0' && ch <= '9' ) x = ( x << 3 ) + ( x << 1 ) + ch - '0' , ch = getchar();
    return x * f;
}

int32_t main(){
    int n = read();
    int res = 0 , t = INT_MAX;
    for( int i = 1 ; i <= n ; i ++ ){
        for( int j = 1 , x ; j <= n ; j ++ ){
            cin >> x;
            res += x;
            if( (i+j) & 1 ) t = min( t , x );
        }
    }
    if( n % 2 == 0 ) res -= t;
    cout << res << "\n";
}
posted @ 2023-01-08 15:16  PHarr  阅读(30)  评论(0编辑  收藏  举报