First round

I'm ready to sort out the knowledge points. I said before that I want to brush the bill of lading (all green) of kuangbin, but the dp has not been written yet. Let's make up for the Niu Ke game first, I don't want to sign in.

B brackets

Looking for regular questions, the first thing I thought about was a left parenthesis, and the rest of the right parentheses had a limit on the number. So split into a left parenthesis and b right parenthesis, but a b=k is required. Some k cannot be split into (a+b<=1e5) satisfying conditions a and b, so first pair k -> sqrt(k) , Round down, then do the remainder after division, the remainder means m—m=ka b, put it to the left, then add a right parenthesis to match, put am left parenthesis, and put b right parenthesis—(am) b+m b completes the match.

#include<bits/stdc++.h>
using namespace std;
const int maxn=10010;
const int mod=1e9+7;
typedef long long ll;
ll k;
int main(){
    
    
    cin>>k;
    if(k==0){
    
    
        cout<<")(";
        return 0;
    }
    ll p=sqrt(k);
    ll r=k/p;
    ll l=k%p;
    for(int i=0;i<l;i++) cout<<"(";
    cout<<")";
    for(int i=l;i<p;i++) cout<<"(";
    for(int i=0;i<r;i++) cout<<")";
    return 0;
}

I limit the permutation of non-prime pairs

I thought of it during the game and wrote a loneliness. First divide the odd and even numbers. The even number gcd must not be unique (all divisible by 2). Then you can add two values. Just pick the smallest pair of 3-6 and 5-10. On both sides. Finally, just construct it on demand.

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int f[maxn];
int vis[maxn];
int main(){
    
    
    int n,k;
    cin>>n>>k;
    if(n<=5&&k==n/2) cout<<-1;
    else{
    
    
        vector<int> ve;
        if(k==n/2){
    
    
            for(int i=2;i<=n;i+=2){
    
    
                if(i==6) continue;
                ve.push_back(i);
            }
            ve.push_back(6);
            ve.push_back(3);
            for(int i=1;i<=n;i+=2){
    
    
                if(i==3) continue;
                ve.push_back(i);
            }
        }else{
    
    
            for(int i=2;i<=2*k+2;i+=2){
    
    
                ve.push_back(i);
            }
            for(int i=1;i<=2*k+2;i+=2){
    
    
                ve.push_back(i);
            }
            for(int i=2*k+3;i<=n;i++){
    
    
                ve.push_back(i);
            }
        }
        for(int i=0;i<ve.size();i++){
    
    
            cout<<ve[i]<<" ";
        }
    }
    return 0;
}

Guess you like

Origin blog.csdn.net/iuk11/article/details/113872066