#P1322. logo语言
logo语言
Description
Logo language commands can direct a turtle to crawl on the screen. This problem uses only three Logo statements: forward FD, backward BK, and repeat REPEAT, so the turtle moves back and forth along a single straight line. Given one line of a Logo command line, output the distance between the turtle and its original position (assume the screen is large enough to let the turtle move up to a distance of ).
For example:
- Input
FD 100, output: . - Input
FD 100 BK 150, output: . - Input
REPEAT 5[FD 100 BK 50], output: . - Input
REPEAT 5[FD 50 REPEAT 10[FD 100]], output: .
Input Format
One line containing a string that is a valid Logo command line as specified above.
Output Format
A single number: the distance from the turtle’s original position.
FD 100
100
Hint
The absolute value of each statement’s argument does not exceed . The output will not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号