2020 Jiangxi Province College Student Program Design Competition

B Apple

Insert picture description here
Idea: The question requires that the number of people is different, so suppose that one is given to the first person, and one is added to each person afterwards to see if the required apples are greater than n.

#include <bits/stdc++.h>

using namespace std;

int main()
{
    
    
    int t; cin>>t;
    while(t--){
    
    
        int n,m; cin>>n>>m;
        int cnt = m+m*(m-1)/2;
        if(n<cnt) cout<<"impossible"<<endl;
        else cout<<"possible"<<endl;
    }
    return 0;
}

G Mathematical Practice

Insert picture description here
Insert picture description here
Idea: The problem is to take the sub-sets in order from a set of size, and find the number of schemes where these subsets have no intersection.
Insert picture description here
First of all, we can find that the range of n and m is quite large, and direct violence is definitely not good, so we use fast power to calculate the result we want.

#include <bits/stdc++.h>
using namespace std;
int  mod = 998244353;
int ans;
int fast_power(long long base,long long power,long long mod){
    
    
    long long result = 1;
    while(power>0){
    
    
        if(power&1){
    
    
            result = result*base%mod;
        }
        power>>=1;
        base = (base*base)%mod;
    }
    return result;
}
int main()
{
    
    
    int n,m;cin>>n>>m;
    ans = fast_power(m+1,n,mod);
    cout<<ans<<endl;
    return 0;
}

I Simple Math Problem

Insert picture description here
Enter
5 2 2 and
output
12.
Idea: Give you a matrix and ask you to output the number corresponding to the position. The question is in hexadecimal, and the decimal number is to be output.
To find the law directly, divide the matrix into two parts, the upper triangle and the lower triangle, and then look for it.

#include <bits/stdc++.h>

using namespace std;

int main()
{
    
    
    long long n,x,y; cin>>n>>x>>y;
    long long ans,step;
    long long  e =n*n-1;
    if(x+y<n){
    
    
        ans = 0; step = 1;
        for(int i=0;i<y;i++){
    
    
            ans+=step++;
        }
        step++;
        for(int i=0;i<x;i++){
    
    
            ans+=step++;
        }
    }
    else {
    
    
        ans = e,step = 1;
        for(int i=n-1;i>y;i--){
    
    
            ans-=step++;
        }
        step++;
        for(int i=n-1;i>x;i--){
    
    
            ans-=step++;
        }
    }
    cout<<ans<<endl;
}

M Zoos’s Animal Codes

Sign-in question: Just output two strings directly.

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

int main(){
    
    
    string a,b; cin>>a>>b;
    cout<<a<<b<<endl;
    return 0;
}

Guess you like

Origin blog.csdn.net/qq_43811879/article/details/109750203