/ OPS / 题库 /

AirCraft

AirCraft

#描述#
LCS has an aircraft, he can use some specific commands to make his aircraft to move. To simple the problem, you can assume the aircraft just move on the 2D-Plane.<br />
<br />
There are four commands :fd x, bk x, lt y, rt y.<br />
The command fd causes the aircraft to move forward by the specified number x of meters.<br />
The command bk causes the aircraft to move backward by the specified number x of meters.<br />
The command lt causes the aircraft to turn left by the specified number y of degrees.<br />
The command rt causes the aircraft to turn right by the specified number y of degrees.<br />
<br />
After executing many commands, LCS's aircraft maybe far away from it's start position. Your task is to calculate the straight-line distance from the LCS's aircraft present position to the position it started from.<br />

#格式#
##输入格式##
The first line of input contains one integer specifying the number of test cases to follow. Each test case starts with a line containing one integer, the number of commands to follow. The commands follow, one on each line. Each test case will contain no more than 1000 commands.

##输出格式##
For each test case, output a line containing a single integer indicating the distance rounded to the nearest meter.

#样例1#
##样例输入1##

1
5
fd 100
lt 120
fd 100
lt 120
fd 100

##样例输出1##

0

#限制#
1000ms
32768KB

#提示#

#来源#
LCS

信息

ID
1829
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者