橙题炸了,求调
  • 板块学术版
  • 楼主cjr2009
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/5/20 16:21
  • 上次更新2024/5/20 19:41:43
查看原帖
橙题炸了,求调
371086
cjr2009楼主2024/5/20 16:21

P10510 进制

大样例过了,但全wa了,求调 qq_emoji: bx

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

#define ll long long
#define int unsigned long long
int shu[1000010];
int ans[100010];
int f[100010];
signed main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	int v, q;
	cin >> v >> q;
	int tt = 0, n = v;
	while (n) {
		shu[++tt] = n % 3;
		n /= 3;
	}
	for (int i = 1; i <= tt; i++) {
		ans[i] = shu[i];
	}
	for (int i = 1; i <= q; i++) {
		int op, x;
		cin >> op >> x;
		x++;
		tt = max(tt, x);
		if (op == 1) {
			ans[x]++;
			ans[x] %= 3;
		}
		if (op == 2) {
			ans[x] += 2;
			ans[x] %= 3;
		}
		if (op == 3) {
			if (ans[x] == 1)ans[x]++;
			if (ans[x] == 2)ans[x]--;
		}
		int sum = 0;
		for (int j = 1000; j >= 1; j--) {
			sum = sum*3+ans[j];
		}
		cout << sum << '\n';
	}
	//return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
	return 0;
}
2024/5/20 16:21
加载中...