The 11th Blue Bridge Cup Software Provincial Competition C/C++ University Group B

Insert picture description here

answer:3880

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main()
{
    
    
    int a = 10000, ans = 0;
    while(true)
    {
    
    
        if((ans / 60) & 1)  a += 5;
        else    a -= 10;
        ans++;
        if(a == 0)  break;
    }
    
    printf("%d\n", ans);
    
    return 0;
}

Insert picture description here

answer:52038720

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int leap(int x)
{
    
    
    if((x % 4 == 0 && x % 100 != 0) || x % 400 == 0)    return 366;
    return 365;
}

int main()
{
    
    
    int ans = 344;
    
    for(int i = 1922; i <= 2019; i++)   ans += leap(i);
    
    printf("%d\n", ans * 24 * 60);
    
    return 0;
}

Insert picture description here

Idea: The infection rate is about 1%, which is evenly distributed, which means every 100 1001 0 0 out of1 11 person was infected. Enumkkk , find the one that uses the least kit in the worst casekkk

If 100% k = = 0 100 \% k == 0100%k==0 , it can be divided into100 k \frac{100}{k}k100Group, a total of 100 k − 1 + k + 1 \frac{100}{k}-1 + k + 1k1001+k+1 kit.

If 100% k! = 0 100 \% k! = 0100%k!=0 , it can be divided into100 k \frac{100}{k}k100 组,还剩 r   ( r < k ) r\ (r < k) r (r<k ) people, in the worst case a total of100 k + k + 1 \frac{100}{k} + k + 1k100+k+1 kit.

answer:10

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main()
{
    
    
    int minn = 1e9, mink = 1e9, t;
    for(int k = 1; k <= 100; k++)
    {
    
    
        if(100 % k == 0)    t = 100 / k + k;
        else    t = 100 / k + k + 1;
        
        if(t < minn)
        {
    
    
            minn = t;
            mink = k;
        }
    }
    
    printf("%d\n", mink);
    
    return 0;
}

Insert picture description here

Insert picture description here

Insert picture description hereInsert picture description here

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
const int N = 10010;

int f[N];
int d[N], v[N];

int find(int x)
{
    
    
    if(f[x] != x)
    {
    
    
        int t = find(f[x]);
        d[x] += d[f[x]];
        f[x] = t;
    }
    return f[x];
}

int main()
{
    
    
    int n, m;
    scanf("%d%d", &n, &m);
    
    for(int i = 1; i <= n; i++) f[i] = i;
    
    while(m--)
    {
    
    
        int op, a, b;
        scanf("%d%d%d", &op, &a, &b);
        
        if(op == 1)
        {
    
    
            int fa = find(a), fb = find(b);
            if(fa != fb)
            {
    
    
                f[fa] = fb;
                d[fa] += v[fa] - v[fb];
            }
        }
        else if(op == 2)
        {
    
    
            int fa = find(a);
            v[fa] += b;
        }
    }
    
    for(int i = 1; i <= n; i++) printf("%d ", v[find(i)] + d[i]);
    
    return 0;
}

Guess you like

Origin blog.csdn.net/qq_42815188/article/details/109120052