UVa 11507 Bender B. Rodríguez Problem:模拟&异或

11507 - Bender B. Rodríguez Problem

Time limit: 4.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2502

Bender is a robot built by Mom's Friendly Robot Company at its plant in Tijuana, Mexico in 2996 . He is aBending-Unit 22, serial number 2716057 and chassis number 1729 . He was created for the task of bending metal wires. Bender needs to bend a wire of length L (L

2 an integer). The wire is represented in the Bender's brain (aMOS Technology 6502 microprocessor) as a line stucked in the origin of a tridimensional cartesian coordinate system, and extended along the x positive axis (+x), so that the fixed extreme of the wire is in the coordinate (0,0,0) and the free extreme of the wire is in the coordinate (L,0,0).

Bender bends the wire at specific points, starting at the point (L-1,0,0) and ending at the point (1,0,0). For each i from L-1 to 1, Bender can take one of the following decisions:

Not to bend the wire at point (i,0,0).

To bend the wire at point (i,0,0) an angle of

to be parallel to the axis +y, -y, +z or -z. For example, if L=3 and Bender bends the wire at (2,0,0) on the +y axis direction, and at (1,0,0) on the -yaxis direction, the result would be:

Given a sequence of bends, you must determine what direction is pointed by the last segment of the wire (+xin the example). You can suppose that the wire can intercept itself, after all it is the future!

Input

The first line of each test case gives an integer L (2

L

100000) indicating the length of the wire.

The second line of each test case contains the L-1 decisions taken by Bender at each point, separated by spaces. The j-th decision in the list (for each 1

j

时间: 2024-08-08 16:48:35

UVa 11507 Bender B. Rodríguez Problem:模拟&异或的相关文章

UVa 550 Multiplying by Rotation:模拟乘法

550 - Multiplying by Rotation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=491 Warning: Not all numbers in this problem are decimal numbers! Multiplic

UVa 10026:Shoemaker's Problem

链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=967 类型: 贪心 原题: Shoemaker has N jobs (orders from customers) which he must make. Shoemaker can work on only one job in each day.

UVa 133 The Dole Queue:模拟循环链表

133 - The Dole Queue Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=103&page=show_problem&problem=69 In a serious attempt to downsize (reduce) the dole queue, The New National Green

UVa 327 Evaluating Simple C Expressions (模拟)

327 - Evaluating Simple C Expressions Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=104&page=show_problem&problem=263 The task in this problem is to evaluate a sequence of simple C

IIUC ONLINE CONTEST 2008 / UVa 11389 The Bus Driver Problem:贪心

11389 - The Bus Driver Problem Time limit: 1.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2384 In a city there are n bus drivers. Also there are n morning bus routes

UVa 706 / POJ 1102 LCD Display (模拟)

706 - LCD Display Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=647 http://poj.org/problem?id=1102 A friend of you has just bought a new computer. Until

UVa 729 The Hamming Distance Problem:全排列输出及小细节

729 - The Hamming Distance Problem Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=670 The Hamming distance between two strings of bits (binary integers) is the number of

uva 10245 - The Closest Pair Problem

点击打开链接uva 10245 题目意思:   给定N个点,找到所有点中距离最小的 解题思路: 1:递归+分治 <网上大牛的解释如下> 2在二维空间里,可用分治法求解最近点对问题.预处理:分别根据点的x轴和y轴坐标进行排序,得到X和Y,很显然此时X和Y中的点就是S中的点.            1情况(1):点数小于等于三时:                                  2情况(2):点数大于三时:            3首先划分集合S为SL和SR,使得SL中的每一个点

uva 100 The 3n+1 problem

题目链接: http://www.programming-challenges.com/pg.php?page=studenthome /* The 3n+1 problem 计算每个数的循环节长度,求给定区间的循环节长度的最大值. */ #include<iostream> #include<stdio.h> using namespace std; int jk(int n) { int num=1; while(n!=1) { if(n&1) n+=(n<<