传送门:https://ac.nowcoder.com/acm/contest/5668/B
解题思路:将字符串看成一个首尾相接的“圆形”即可很快求解!
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
string s;
ll n;
char a;
ll num,tar;
int main()
{
ll l;
cin>>s;
cin>>n;
l=s.length();
while(n--)
{
getchar();
scanf("%c%lld",&a,&num);
if(a=='M')
{
tar=(tar+(l+num)%l)%l;
}
else
{
cout<<s[(num-1+tar)%l];
printf("\n");
}
}
return 0;
}