题目链接

A.最值序列

题意:


题解:


/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double,double> pdd;
//const int mod=1e9+7;
const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

ll a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    ll ans=0;
    int i=1;
    if(n&1)i++;
    for(;i<=n;i++){
        if(i<=(n+1)/2)ans=(ans+a[i])%mod;
        else ans=ans*a[i]%mod;
    }
    cout<<ans;
    return 0;
}


B.多重序列

题意:




题解:







AC代码

/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double,double> pdd;
//const int mod=1e9+7;
const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

ll n,m,k,p;
ll Pow(ll a, ll b){
    ll ans = 1;
    while(b > 0){
        if(b & 1){
            ans = ans * a % p;
        }
        a = a * a % p;
        b >>= 1;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    cin>>n>>m>>k>>p;
    ll ans=0;
    if(k==1){cout<<1;return 0;}
    for(int i=1;i<=n;i++){
        ll tmp=0;
        for(int j=1;j<=m;j++){
            ll x;
            cin>>x;
            x/=k;
            while(x)x/=k,tmp++;
        }
        ans=max(ans,tmp);
    }
    cout<<Pow(k,ans);
    return 0;
}


C.二维动点

题意:





题解:























AC代码

/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double,double> pdd;
//const int mod=1e9+7;
const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

ll a[maxn],xx[maxn],yy[maxn];
ll b[maxn];
bool ok(ll x,ll y){
    if((xx[1]-x)*yy[2]-(yy[1]-y)*xx[2])return 0;
    if((xx[2]-x)*yy[1]-(yy[2]-y)*xx[1])return 0;
    return 1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,q;
    cin>>n>>q;
    set<pii> s;
    for(int i=1;i<=n;i++){
        cin>>xx[i]>>yy[i];
        if(!xx[i]&&!yy[i]){i--,n--;continue;}
        int tmp=__gcd(xx[i],yy[i]);
        s.insert(mp(xx[i]/tmp,yy[i]/tmp));
    }
    while(q--){
        ll x,y;
        cin>>x>>y;
        if(!x&&!y){cout<<0<<endl;continue;}
        int tmp=__gcd(x,y);
        bool f=0;
        if(ok(x,y))f=1;
        x/=tmp,y/=tmp;
        if(s.count(mp(x,y)))cout<<1<<endl;
        else if(s.size()<=1)cout<<-1<<endl;
        else {
            if(n>2)cout<<2<<endl;
            else{
                if(f)cout<<3<<endl;
                else cout<<2<<endl;
            }
        }
    }
    return 0;
}


D. 最小公倍数

题意:



题解:
















AC代码

/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, ll> pll;
typedef pair<double,double> pdd;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

int prime[maxn];
bool isprime[maxn];
int num=0;
void Prime(int n){
    memset(isprime,true,sizeof(isprime));
    for(int i=2;i<=n;i++){
        if(isprime[i]) prime[++num]=i;
        for(int j=1;j<=num;j++){
            if(i*prime[j]>maxn) break;
            isprime[i*prime[j]]=false;
            if(i%prime[j]==0) break;
        }
    }
}
pll dp[maxn] ;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    Prime(100000);
    int n;
    ll sum=0;pll ans=mp(0,1);
    cin>>n;
    dp[0]=mp(0,1);
    for(int i=1;i<=n;i++){
        for(int j=n;j>=1;j--){
            ll x,y,k=1;
            x=y=prime[i];
            while(x<=j){
                dp[j]=max(dp[j],mp(dp[j-x].fi+log2(k+1),dp[j-x].se*(k+1)%mod));
                y*=prime[i],k++,x+=y;
            }
            ans=max(ans,dp[j]);
        }
        sum+=prime[i];
        if(sum>n)break;
    }
    cout<<ans.se;
    return 0;
}


E.游走配对

题意:






题解:







AC代码

/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double,double> pdd;
//const int mod=1e9+7;
const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

//spfa
int n,m,s,t,N;
struct edge{
    ll v,nx,f,w;
}e[1000010];
int cnt,maxflow,maxcost;
ll head[maxn],dis[maxn],pre[maxn],maxf[maxn];
bool inq[maxn];
void add(int u,int v,int f,int w){
    e[cnt]={v,head[u],f,w};
    head[u]=cnt++;
    e[cnt]={u,head[v],0,-w};
    head[v]=cnt++;
}
void init(){
    for(int i=0;i<=N;i++)
        head[i]=-1;
    maxflow=maxcost=cnt=0;
}
bool spfa(){
    for(int i=0;i<=N;i++)dis[i]=inf;
    queue<int> q;
    q.push(s);
    dis[s]=0,inq[s]=1,maxf[s]=inf;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        inq[u]=0;
        for(int i=head[u];i!=-1;i=e[i].nx){
            int v=e[i].v;
            if(e[i].f&&dis[v]>dis[u]+e[i].w){
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                maxf[v]=min(maxf[u],e[i].f);
                if(!inq[v])inq[v]=1,q.push(v);
            }
        }
    }
    return dis[t]<inf;
}
void MCMF(){
    while(spfa()){
        int u=t,i;
        while(u!=s){
            i=pre[u];
            e[i].f-=maxf[t];
            e[i^1].f+=maxf[t];
            u=e[i^1].v;
        }
        maxflow+=maxf[t];
        maxcost+=dis[t]*maxf[t];
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m,q;
    cin>>n>>m>>q;
    N=t=2*n+1;
    init();
    for(int i=1;i<=n;i++){
        ll a,b;
        cin>>a>>b;
        for(int j=0;j<q;j++)
            add(i,i+n,1,a+j*b);
    }
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        add(u+n,v,inf,0);
        add(v+n,u,inf,0);
    }
    for(int i=1;i<=q;i++){
        int x;cin>>x;
        add(s,x,1,0);
    }
    for(int i=1;i<=q;i++){
        int y;cin>>y;
        add(y+n,t,1,0);
    }
    MCMF();
    cout<<maxcost;
    return 0;
}