- 问答
GC6-考题案例《树上漫步》
- @ 2025-9-12 23:56:30
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,p;
string s;
cin>>n>>p>>s;
for(int i=0;i<n;i++){
if(s[i]=='U'){
if(p>1)p=p/2;
}
else if(s[i]=='L'){
if(p<500000000000)p=p*2;
}
else if(p<499999999999)p=p*2+1;
}
cout<<p;
return 0;
}
0 条评论
目前还没有评论...