新生赛题解

A

题解:不会

#include <bits/stdc++.h>
#pragma  GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
//#define double long double
#define int long long
#define endl '\n';
using namespace std;
const int N=3e5+8,M=1e1;
const int INF = 0x3f3f3f3f;
const int mod=998244353;
typedef pair<int,int> PII;


int32_t  main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n,x,t;
    cin>>n>>x>>t;
    int y=n/x;
    if(n%x)
    {
        y++;
    }
    cout<<y*t;
    return 0;
}

 

B

题解:不会

#include <bits/stdc++.h>
#pragma  GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
//#define double long double
#define int long long
#define endl '\n';
using namespace std;
const int N=3e5+8,M=1e1;
const int INF = 0x3f3f3f3f;
const int mod=998244353;
typedef pair<int,int> PII;


int32_t  main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s;
    cin>>s;
    int ans=s.length();
    if(ans%2==0)
    {
        ans-=2;
        while (s.substr(0,ans/2)!=s.substr(ans/2,ans/2))
        {
            ans-=2;
        }
    }
    else
    {
        ans-=1;
        while (s.substr(0,ans/2)!=s.substr(ans/2,ans/2))
        {
            ans-=2;
        }
    }
    cout<<ans;
    return 0;
}

 

C

题解:开__int128

#include <bits/stdc++.h>
#pragma  GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
//#define double long double
#define int long long
#define endl '\n';
using namespace std;
const int N=3e5+8,M=1e1;
const int INF = 0x3f3f3f3f;
const int mod=998244353;
typedef pair<int,int> PII;

int a[N];
int32_t  main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    __int128 b=1,c=1e18;
    for(int i=1;i<=n;i++)
    {
        b*=a[i];
        if(b>c)
        {
            b=-1;
            break;
        }
    }
    int k=b;
    cout<<k;
    return 0;
}

 

D

题解:直接暴力即可

#include <bits/stdc++.h>
#pragma  GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
//#define double long double
#define int long long
#define endl '\n';
using namespace std;
const int N=3e5+8,M=1e1;
const int INF = 0x3f3f3f3f;
const int mod=998244353;
typedef pair<int,int> PII;

int a[N];
int32_t  main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++)
        {
            int x=s-i-j;
            if(x<=k && x>=0)
            {
                ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

 

E

题解:直接模拟一下过程以成年人为基准,那么这题可能小孩的成年人的体重会有交接,所以我们把成年人全加上然后在这个体重下减,要么去掉这个体重的成年人,这里map自动排序,要么不要大于这个体重的小孩,对于这个取一个MAX即可

#include <bits/stdc++.h>
#pragma  GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
//#define double long double
#define int long long
#define endl '\n';
using namespace std;
const int N=3e5+8,M=1e1;
const int INF = 0x3f3f3f3f;
const int mod=998244353;
typedef pair<int,int> PII;

map<int,int> a;
int ans=0;

int32_t  main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin>>n;
    string s;
    cin>>s;
    int res=0;
    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        if (s[i] == '1') {
            res++;
            a[x]--;
        } else {
            a[x] += 1;
        }
    }
        ans=res;
        for(auto i:a)
        {
            res+=i.second;
            ans=max(ans,res);
        }
        cout<<ans;
    return 0;
}

 

F

这题不是特别恶心,你们也有人过,可以相互问问,我就不做过多解释了

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxx 1145141919810ll
#define minx -1145141919810ll
int n,m;
int a[100100];
int b[100100];
struct Node{
    int x,y,z;
};
Node c[200100];
bool cmp(Node x,Node y){
    return x.x < y.x;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i=1;i<=n;i++){
        int temp;
        cin >> temp;
        c[i].x = temp;
        c[i].y = 1;
        c[i].z = i;
    }
    for (int i=1;i<=m;i++){
        int temp;
        cin >> temp;
        c[n+i].x = temp;
        c[n+i].y = 2;
        c[n+i].z = i;
    }
    sort(c+1,c+n+m+1,cmp);
    for (int i=1;i<=n+m;i++){
        if (c[i].y == 1){
            a[c[i].z] = i;
        }
        else {
            b[c[i].z] = i;
        }
    }
    for (int i=1;i<=n;i++){
        cout << a[i] << " ";
    }
    cout << endl;
    for (int i=1;i<=m;i++){
        cout << b[i] << " ";
    }
    return 0;
}

 

posted @ 2023-08-16 19:01  whatdo+  阅读(22)  评论(0编辑  收藏  举报