每个输入包含一个测试用例。
每个测试用例的第一行包含一个正整数,表示转方向的次数N(N<=1000)。
接下来的一行包含一个长度为N的字符串,由L和R组成,L表示向左转,R表示向右转。
输出牛牛最后面向的方向,N表示北,S表示南,E表示东,W表示西。
3 LRR
E
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(reader.readLine().trim());
String str = reader.readLine().trim();
String[] d = {"N", "W", "S", "E", "N"};
int res = 0;
for(int i=0;i<n;++i) {
if(str.charAt(i) == 'L') {
++res;
}else {
--res;
}
}
if(res >= 0) {
System.out.println(d[res%4]);
}else {
res = -res;
System.out.println(d[4-res%4]);
}
}
}
#默认为北方,北,东,南,西 outstr = 'NESW' point = 0 n = input() n = int(n) letter = input() for i in letter: if i=='L': point-=1 else: point+=1 if point>0 and point ==4: point = 0 elif point<0 and point==-5: point = 3 print(outstr[point])
if __name__ == '__main__': count = int(input()) string1 = input() countl=0 countr=0 for i in range(count): if string1[i]=='L': countl+=1 else:countr+=1 if countl>=countr: flag=1 else:flag=0 if abs(countl-countr)%4==0: print('N') elif abs(countl-countr)%4==2: print('S') else: pnum=(abs(countl-countr)%4)//2 flag=(1-flag)*pnum+flag*(1-pnum) print('%s'%('W'*flag+'E'*(1-flag)))