零点工作室暑假集训(牛客周赛 Round 3)

A - 游游的7的倍数

题意:在这里插入图片描述

思路:可以将该数先乘10后使其个数位为0;然后从0 ~ 6循环每次加1;因为7的倍数每7次就会有一次

AC代码

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

const int N = 100010, INF = 0x3f3f3f3f, mod = 998244353;

LL x;

int main() 
{
    cin >> x;
    LL a = x * 10;
    for(int i = 0; i <= 6; i ++)
    {
        LL b = a + i;
        if(b % 7 == 0)
        {
            cout << b << endl;
            return 0;
        }
    }
}

B - 游游的字母串

题意:在这里插入图片描述

思路: 因为数据不是很大。直接枚举所有方式即可,考虑到首尾的a,z连接到一起那么就有abs(a[i]-i) 和26-abs(a[i]-i) 也就是两种最快的逼近方式

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 100010, INF = 0x3f3f3f3f, mod = 998244353;


void solved()
{
    string s;
    cin >> s;
    
    int n = s.size();
    
    int minop = INF;
    
    for(char i = 'a'; i <= 'z'; i ++)
    {
        int op = 0;
        for(int j = 0; j < n; j ++)
        {
            int d = abs(i - s[j]);
            op += min(d, 26 - d);
        }
        minop = min(minop, op);
    }
    
    cout << minop;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

C - 游游的水果大礼包

题意: 在这里插入图片描述

思路:直接枚举一种礼包的数量所有的情况即可然后对剩下的直接计算另一个的数量即可,考虑最小的情况,因为大礼包需要二者的数量都满足

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 100010, INF = 0x3f3f3f3f, mod = 998244353;

LL t, n, m, a, b;

void solved()
{
   cin >> n >> m >> a >> b;
   LL num = min(n / 2, m);
   LL ans = 0;
    for(LL i = 0; i <= num; i ++)
    {
        LL res = i * a;
        res += min(n - 2 * i, (m - i) / 2) * b;
        ans = max(ans, res);
    }
    cout << ans << endl;
    
    return ;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

D - 游游的矩阵权值

题意: 在这里插入图片描述

思路: 我们可以明显发现只要最大的越里面总和就越大,那么我们可以试着模拟一下四个角落的数每个数都只会加2次,其他边上的数都会加3次里面的数都是4次就好了,对于里面的数计算出个数就是用等差数列就好了,详情见代码 注意中间的取模操作mod
在这里插入图片描述

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 100010, INF = 0x3f3f3f3f, Mod = 1e9 + 7;



void solved()
{
    LL n;
    cin >> n;
     
    LL x = 4 * n - 4;
     
    cout << (20 + ((x - 4) / 2) % Mod * (x + 5) % Mod * 3 % Mod + 2 * (n - 2) % Mod * (n - 2) % Mod * (x + 1 + n * n % Mod) % Mod) % Mod << endl;

     
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //int t;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值