2024笔试

T1

#include <bits/stdc++.h>

using namespace std;

#define ios ios::sync_with_stdio(false), cin.tie(0)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define debug(x) cout << #x << ": " << x << endl
typedef long long LL;

/************************Gusil************************/
const int N = 1e5 + 10;


int main()
{
    int k , x , y;
    cin >> k >> x >> y ;
    
    int c = (k + x - y )/ 3;
    cout << c - x << " " << c + y  << " " <<  c << endl;

    return 0;
}

T2

#include <bits/stdc++.h>

using namespace std;

#define ios ios::sync_with_stdio(false), cin.tie(0)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define debug(x) cout << #x << ": " << x << endl
typedef long long LL;

/************************Gusil************************/
const int N = 2e5 + 10;
int n;
int a[N];

int main() 
{
    ios;
    cin >> n;
    int mx = -INT_MAX;
    rep(i , 1 , n)
    {
        cin >> a[i];
        mx = mx > a[i] ? mx : a[i];
    }
    rep(i , 1 , n)
    {
        int t = a[i] * 2;
        if(t > mx) cout << t << " ";
        else cout << mx << " ";
    }

    return 0;
}

T3

#include <bits/stdc++.h>

using namespace std;

#define ios ios::sync_with_stdio(false), cin.tie(0)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define debug(x) cout << #x << ": " << x << endl
typedef long long LL;

/************************Gusil************************/
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
    ios;
    set<char> a ,b;
    string s1 , s2;
    cin >> s1 >> s2;
    int n = s1.size();
    if(s1 == s2)
    {
        cout << 0 << endl;
        return 0;
    }
    int pre1[N] ,pre2[N] , m = 0;

    rep(i , 0 , n-1)
    {
        a.insert(s1[i]);
        pre1[i] = a.size();
        b.insert(s2[i]);
        pre2[i] = b.size();
    }

    per(i , 0 , n-1)
    {
        if(s1[i] == s2[i]) continue;

        if(pre1[i] == 1 || pre2[i] == 1)
        {
            cout << 1 << endl;
            if(pre1[i] == 1) cout << 2 << ' ' << i + 1 << ' ' << s1[i];
            else cout << 1 << ' ' << i + 1 << ' ' << s2[i];
            return 0;
        }
        else 
        {
            cout << 2 << endl;
            cout << 1 << ' ' << i + 1 << ' ' << s1[i]<<endl;
            cout << 2 << ' ' << i + 1 << ' ' << s1[i]<<endl;
            return 0;
        }
    }


    return 0;
}

T4

#include <bits/stdc++.h>

using namespace std;

#define ios ios::sync_with_stdio(false), cin.tie(0)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define debug(x) cout << #x << ": " << x << endl
typedef long long LL;

/************************Gusil************************/
const int N = 2e5 + 10 , mod = 1e9 + 7;
int fact[N], infact[N];
unordered_map<char, int> mp;
vector<pair<char, int> > res;

int qmi(int a, int k , int p)
{
    int res = 1;
    while (k)
    {
        if(k & 1) res = (LL) res* a% p;
        a= (LL) a * a % p;
        k >>= 1;
    }
    return res;
}


int main()
{
    fact[0] = infact[0] = 1;
    rep(i , 1 , N - 1)
    {
        fact[i] = (LL) fact[i - 1] * i % mod;
        infact[i] = (LL) infact[i - 1] * qmi(i, mod - 2, mod) % mod;
    }

    int n;
    cin >> n;
    string s;
    cin >> s;
    LL ans = 0;

    rep(i, 0, n - 1)
        mp[s[i]]++;

    for (auto t : mp)
    {
        res.push_back({t.first,t.second});
    }
    
    rep(i , 0 ,res.size() -1)
    {
        rep(j , i + 1 ,res.size() -1)
        {
            if(i == j) continue;
            int ress = min(res[i].second , res[j].second);
            int n1 = res[i].second , m1= res[j].second ;;
            int maxx = min(n1, m1);
            rep(k , 1 , maxx)
            {
                LL xx = (LL) fact[n1] * infact[k]%mod * infact[n1 - k] % mod;
                LL yy = (LL) fact[m1] * infact[k]%mod * infact[m1 - k] % mod;
                ans = (ans + xx * yy % mod) % mod;
            }
        }
    }
    cout << ans % mod;
    return 0;
}

T5
当时没写完,回头再补吧

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

息息在努力吖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值