提交时间:2021-05-23 09:59:23

运行 ID: 19815

#include<bits/stdc++.h> using namespace std; int n,k,loc; string c; int main(){ cin>>n>>k>>c; loc=c.length()-1; for(int i=0;i<=loc;i++){ switch(c[i]){ case 'a':n*=k,n%=1000; break; case 'b':n+=k,n%=1000; break; case 'c':n=abs(n-k); break; case 'd':n/=k; break; } } cout<<n; return 0; }