ZR#1008

解法:

CODE:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define LL long long
#define N 5050

char ch[N];
int pos1,pos2,T,cnt1,cnt2,x,y;

int main() {
    scanf("%s",ch + 1);
    scanf("%d",&T);
    int len = strlen(ch + 1);
    for(int i = 1 ; i <= len ; i++) {
        if(ch[i] == 'N') y++;
        if(ch[i] == 'S') y--;
        if(ch[i] == 'W') x--;
        if(ch[i] == 'E') x++;
    }
    //cout<<len<< " "<<T;
    //if(len > T) {
        cnt1 = len / T,cnt2 = len % T;
        x = cnt1 * x,y = cnt1 * y;
        for(int i = 1 ; i <= cnt2 ; i++) {
            if(ch[i] == 'N') y++;
            if(ch[i] == 'S') y--;
            if(ch[i] == 'W') x--;
            if(ch[i] == 'E') x++;
        }
    //}
    printf("%d %d\n",x,y);
    //system("pause");
    return 0;
}
01-26 09:59