代码如下
#include<bits/stdc++.h>
using namespace std;
int main() {
long long x, k;
cin >> x >> k;
long long ans=0;
if (k <= 1e6) {
for (int i = 1; i <= k; i++) {
x += 1;
if (x % 3 == 0)x /= 3;
ans++;
}
cout << x;
}
else{
int flag=0;
for (int i = 1; i <= k; i++) {
x += 1;
if (x % 3 == 0)x /= 3;
if(x==1){
flag=1;
break;
}
ans++;
}
ans-=1;
if(flag==0){
cout<<x;
}
else{
cout<<(k-ans)%3;
}
}
return 0;
}
很奇怪,有两个子任务都只对了一般