Codeforces Round 957 (Div. 3) A - E

 Codeforces Round 957 (Div. 3) A - E_哔哩哔哩_bilibili

视频讲解噢

A - Only Pluses

#include <bits/stdc++.h>
using namespace std;
int main()
{

	int t;
	cin >> t;
	while (t--)
	{
		vector<int> a(3);
		for (auto &i : a)
			cin >> i;
		for (int i = 0; i < 5; i++)
		{
			sort(a.begin(), a.end());
			a[0]++;
		}
		cout << a[0] * a[1] * a[2] << endl;
	}
	return 0;
}

B - Angry Monk

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        int n, k, sum = 0;
        cin >> n >> k;
        vector<int> a(k);
        for (auto &i : a)
            cin >> i;
        sort(a.begin(), a.end());
        for (int i = 0; i < k - 1; i++)
            sum += a[i];
        cout << 2 * sum - (k - 1) << endl;
    }
    return 0;
}

C - Gorilla and Permutation

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{

	int t;
	cin >> t;
	while (t--)
	{
		int n, m, k;
		cin >> n >> m >> k;
		vector<int> a(n);
		for (int i = 1; i <= n; i++)
			a[n - i] = i;
		sort(&a[n - m], &a[n]);
		for (auto i : a)
			cout << i << ' ' ;
		cout << endl;
	}
	return 0;
}

D - Test of Love

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, m, k;
		cin >> n >> m >> k;
		vector<int> a(n + 1, 0);
		string s;
		cin >> s;
		for (int i = 0; i < m && i < n + 1; i++)
			a[i] = 1;
		for (int i = 0; i < n; i++)
		{
			int index = i + 1;
			if (s[i] == 'L')
				for (int j = 0; j < m && index + j < n + 1; j++)
					a[index + j] = 1;
		}
		int cnt = 0;
		bool cor = false;
		for (int i = 1; i <= n; i++)
		{
			char c = s[i - 1];
			if (c == 'W' && !a[i])
				cnt++;
			if (c == 'C' && !a[i])
				cor = true;
		}
		cout << (cnt > k || cor ? "NO\n" : "YES\n");
	}
	return 0;
}

E - Novice's Mistake

#include <bits/stdc++.h>
using namespace std;
#define int long long

int getDig(int a)
{
	int cnt = 0;
	if (a == 0)
		return 1;
	while (a > 0)
		a /= 10, cnt++;
	return cnt;
}

signed main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<pair<int, int>> ans;
		for (int a = 1; a <= 10000; a++)
		{
			int d = getDig(n), stringDig = a * d, maxRealDig = getDig(n * a);
			for (int realDig = maxRealDig; realDig > 0; realDig--)
			{
				int b = stringDig - realDig;
				if (!(b >= 1 && b <= min(10000LL, a * n)))
					continue;
				string s = to_string(n);
				string ss = s + s + s + s + s + s + s + s + s + s + s + s + s;
				s = ss.substr(0, realDig);
				// cout << s << endl;
				int result = stoi(s);
				int compare = n * a - b;
				if (result == compare)
					ans.push_back({a, b});

			}
		}
		cout << ans.size() << endl;
		for (auto i : ans)
			cout << i.first << ' ' << i.second << endl;
	}
	return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值