UNIQUE VISION Programming Contest 2022 Winter(AtCoder Beginner Contest 283) A~C

A - Power

#include 

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (long long)pow(a,b);

	return 0;
}

B - First Query Problem

模拟

#include 

using namespace std;

const int N = 1e5 + 10;
int a[N];
int n;

int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];

	int q;
	cin >> q;
	while(q--) {
		int op;
		cin >> op;

		if(op == 1) {
			int k, x;
			cin >> k >> x;
			a[k-1] = x;
		}
		else {
			int k;
			cin >> k;
			cout << a[k-1] << endl;
		}
	}

	return 0;
}

C - Cash Register

遇到连续的两个0当成一个即可

#include 

using namespace std;

typedef long long ll;

int main() {
	string s;
	cin >> s;
	ll res = s.size();
	for(int i = 1; i < s.size(); i++) {
		if(s[i] == '0' && s[i-1] == '0') {
			res--;
			i++;
		}
	}
	cout << res;
	return 0;
}

你可能感兴趣的:(AtCoder,c语言,c++,算法)