标签:sam output array inpu end 方向 str play 100%
NSWWNSNEEWN 12
-1 3
1 var 2 i,j,x,y,c,t:longint; 3 l,r:array[1..100000] of longint; 4 a:ansistring; 5 begin 6 readln(a); 7 readln(t); 8 c:=length(a); 9 x:=0;y:=0; 10 for i:=1 to c do 11 begin 12 if a[i]=‘N‘ then 13 inc(y); 14 if a[i]=‘S‘ then 15 dec(y); 16 if a[i]=‘W‘ then 17 dec(x); 18 if a[i]=‘E‘ then 19 inc(x); 20 l[i]:=x; 21 r[i]:=y; 22 end; 23 x:=0;y:=0; 24 while (t<>0) do 25 if (t>=c) then 26 begin 27 x:=x+(t div c)*l[c]; 28 y:=y+(t div c)*r[c]; 29 t:=t mod c; 30 end 31 else 32 begin 33 x:=x+l[t]; 34 y:=y+r[t]; 35 t:=0; 36 end; 37 writeln(x,‘ ‘,y); 38 end.
标签:sam output array inpu end 方向 str play 100%
原文地址:https://www.cnblogs.com/Tokisaki-Kurumi/p/9532923.html