代码:
#include<bits/stdc++.h>
using namespace std;
string s;
long long jx,jy;
long long x,y;
int t;
int main(){
cin>>s>>t;
for(int i=0;i<s.size();i++){
if(s[i]=='N'){
jy++;
}else if(s[i]=='S'){
jy--;
}else if(s[i]=='E'){
jx++;
}else if(s[i]=='W'){
jx--;
}
}
x=jx*(t/s.size());
y=jy*(t/s.size());
for(int i=0;i<t%s.size();i++){
if(s[i]=='N'){
y++;
}else if(s[i]=='S'){
y--;
}else if(s[i]=='E'){
x++;
}else if(s[i]=='S'){
x--;
}
}
cout<<x<<' '<<y;
return 0;
}