1413. Mars Jumper
来源:互联网 发布:spring启动时加载数据 编辑:程序博客网 时间:2024/04/29 07:44
原题链接: http://acm.timus.ru/problem.aspx?space=1&num=1413
对小键盘的 1- 9 , 0 作为控制源, 分别能够让 机器人不同方向前进 ( 长度为1米) 5不动. 0 是自动销毁.
对一输入的一串字符串 求最终位置.
1413. Mars Jumper
Time limit: 0.5 second
Memory limit: 64 MB
Memory limit: 64 MB
Mars Jumper is a new improved model of Moon Rover. Clever heads from the engineering department proved that in the conditions of low gravity it's easier to jump, so the new vehicle moves by jumping. By the way, the length of its jump is always one meter. Mars Jumper is controlled with a standard computer keyboard. To assign the direction of jumping, one uses the complementary digit keys (those which are on the right). It is very convenient and handy: 8 means a jump northward, 2 means a jump southward, 6 means a jump eastward, 7 means a jump to the north-west, and so on. 5 is an order to take a sample of soil. In order to use the zero key, the chief engineer invented one more function: if this key is pressed, the motor of the vehicle is self-destroyed. He thinks that this function could be very useful.
Of course, to operate the Jumper is not an easy task. Not anyone can quickly move the vehicle, for example, half a meter to the north. According to the designers, Mars Jumper can jump to a position arbitrarily close to any specied point by means of a finite number of jumps.
The customers agreed to pay for the design and manufacture of Mars Jumper only after a trial. To conduct a trial, the chief engineer seated his daughter at a computer and oered her to press some buttons. The result of the trial was that the Jumper had jumped away. Now the engineers need to find it urgently.
Your task is to tell the search team where to find the Jumper. You know that the vehicle stopped at the moment when the zero key was first pressed, or, if this key was not pressed, at the end of the route determined by the sequence of pressed keys. You are given this sequence. You must determine the final position of Mars Jumper. The testing area is considered to be an innite plane.
Input
Not more than 106 digits from 0 to 9.
Output
You should output the final coordinates of Mars Jumper (in meters, accurate to 10 decimal places) in the form X Y, where X is the displacement of the Jumper from the initial point to the east and Y is its displacement to the north.
Sample
1236987412369870234567890123456789
1.0000000000 0.0000000000
Problem Author: Stanislav Vasilyev
ruby 的代码没有写 看到了别人的 c++ 格式挺喜欢 转到这里.
c ++ code
/* * ACM Timus Online * Mars Jumper - Problem 1413 */#include <stdio.h>double X, Y;#define rad2 0.70710678118654752440084436210485int main(){ char ch; X = Y = 0; while (scanf("%c", &ch) == 1 && ch != '0') { switch (ch) { case '1': X -= rad2; Y -= rad2; break; case '2': Y--; break; case '3': X += rad2; Y -= rad2; break; case '4': X--; break; case '6': X++; break; case '7': X -= rad2; Y += rad2; break; case '8': Y++; break; case '9': X += rad2; Y += rad2; break; } } printf("%.10lf %.10lf\n", X, Y); return 0;}
- 1413. Mars Jumper
- Jolly Jumper
- My jumper
- MARS
- Mars
- 电影jumper观后感:恶俗
- pku 2575 Jolly Jumper
- uva-10038- Jolly Jumper
- jumper longest path --pending--
- sgu-204 Little Jumper
- ACdream 1221 Little Jumper
- acdream1221Little Jumper+三分
- PC110201 Jolly Jumper //水题,hash
- 【Unity3D】夏日大作战Jumper~
- PC/UVa 题号: 110201/10037 Jolly Jumper
- Super Jumper:一个2DOpenGL ES游戏
- Super Jumper:一个2DOpenGL ES游戏
- zoj 2340 Little Jumper(数学题,三分)
- 端口复用
- 【启动盘中集成多个PE的几个步骤你知道吗】
- VC调试技巧
- 2012年 中国MCU市场排名 更新
- 生产者-消费者问题
- 1413. Mars Jumper
- 一个ViewSwitcher引发的血案!
- 如何将12.04ubuntu unity界面返回到gnome图形界面
- 05-CMD_for命令详解_变量
- 用 javamail 实现发邮件遇到的问题
- IOS开发之路-C 学习笔记7.12
- struts2的请求过程
- 各种rtos(实时操作系统)比较
- android中文乱码解决大全