rt,直接模拟即可,code :
#include <bits/stdc++.h>
#define ll __int128
#define db double
#define endl "\n"
namespace fastio {
char buf[1 << 21], *p1 = buf, *p2 = buf;
const ll getc() {
return p1 == p2 && ( p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1 ++;
}
const ll read() {
ll x = 0, f = 1;
char ch = getc();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1; ch = getc();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getc();
}
return x * f;
}
const void write(ll x) {
if (x < 0) {
putchar('-'), x = -x;
}
ll sta[35], top = 0;
do {
sta[top++] = x % 10, x /= 10;
} while (x);
while (top) putchar(sta[--top] + 48);
}
}
using namespace std;
ll n = fastio::read(), s = fastio::read(), ans = s, op;
ll work(ll x, ll opt) {
if (opt == 1) {
if (x <= 1) {
return 1;
} else {
return (x % 2 == 1 ? (x - 1) / 2 : x / 2);
}
} else if (opt == 2) {
return x * 2;
} else {
return x * 2 + 1;
}
}
int main() {
for (ll i = 1; i <= n; i++) {
char opt = fastio::getc();
if (opt == 'U') {
op = 1;
} else if (opt == 'L') {
op = 2;
} else if (opt == 'R') {
op = 3;
}
ans = work(ans, op);
}
fastio::write(ans);
}
但是只对了前两个 sub + #15,求调。