【Codeforces】Codeforces Round 863 (Div. 3) (补赛)

 A Insert Digit

题目大意:

解题思路:

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int n, m, d;
string s;
int main() {
	cin >> n;
	while (n--) {
		cin >> m >> d >> s;
		int t = -1;
		for (int i = 0; i < m; i++) {
			if (d > s[i] - '0') {
				t = i;
				break;
			}
		}

		for (int i = 0; i < m; i++) {
			if (i == t) cout << d;
			cout << s[i];
		}
		if (t == -1) cout << d;
		cout << endl;
	}
	return 0;
}

Conveyor Belts

题目大意:

解题思路:

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int t, n;
int sx, sy, fx, fy;
inline int f(int x) {
	if (x > n / 2) x = n + 1 - x ;
	return x;
}
int main() {
	cin >> t;
	while (t--) {
		cin >> n >> sx >> sy >> fx >> fy;
		sx = f(sx), sy = f(sy), fx = f(fx), fy = f(fy);
		cout << abs(min(sx, sy) - min(fx, fy)) << endl;
	}
	return 0;
}

Restore the Array

题目大意:

解题思路:

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int t, n;
int main() {
	cin >> t;
	while (t--) {
		cin >> n;
		int a[n + 1] = {};
		int b[n + 1] = {};
		for (int i = 1; i < n; i++) cin >> b[i];
		a[1] = b[1];
		for (int i = 2; i <= n - 1; i++) {
			a[i] = min(b[i - 1], b[i]);
		}
		a[n] = b[n - 1];
		for (int i = 1; i <= n; i++) cout << a[i] << ' ';
		cout << endl;
	}
	return 0;
}

Umka and a Long Flight

题目大意:

解题思路:

参考代码:

Living Sequence

题目大意:

解题思路:

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll t, k;
stack<int>s;
int main() {
	cin >> t;
	while (t--) {
		cin >> k;
		while (k) s.push(k % 9), k /= 9;
		while (!s.empty()) cout << (s.top() < 4 ? s.top() : s.top() + 1), s.pop();
		cout << endl;
	}
	return 0;
}

F

G1

G2

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值