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;
}