We have to make a pipeline (gas pipeline). We have some pieces of pipes that is on the same line we want the pipeline on. But they are scattered on the entire line and are different sizes-
Now we have to move all the pieces and solder to make one single piece- so that we can order a single piece for the remaining legth-
Now we want to do this with least movement of the pieces- The larger the piece the more the cost- Cost is same for long distance or long distance because the most costly operation is loading and unloading the pipe on the truck-
3 integers each line separated by comma-
piece number , length of the piece, the starting position
2 integers each line separated by comma-
piece number, move to position-
While moving you can not move a large piece in a small gap of two pieces-
1, 10, 5
2, 30, 30
3, 90, 5
4, 130, 20
Monday, September 13, 2010
Wednesday, September 1, 2010
Problem DescriptionWe use letters (A-Z) and digits (0-9) to represent a number. For example A0 in hexadecimal number is equal to 160 in decimal number and 240 in octal number. Given 2 numbers which are equal in two different base and given base of one number you have to find out base of another number.
InputThree words in each line separated by spaces: first word is first number and second word is base of first number in decimal and third word is a number that is equal to first number for some different base. Letters will be capital always.
Print out the base of second number in decimal and zero if can not find any base that is 2-36.
Sample inputA0 16 160
160 10 240
Monday, August 30, 2010
Problem DescriptionWrite a program that takes two integer numbers and find the distance between them.
Sequence of two numbers that fits in 4 byte integer in a computer in each line separated by whitespace character.
Distance between each pair in each line.
Sample input1 2