You are on page 1of 7

Greetings From Globussoft

 Given below are 5 Programming questions, you have to solve any


3 out of 5 questions.

 These 5 questions you can attempt in any technology like C/C++,


java, .Net

 To solve these 5 questions you’ve max. 3 hours.

 While solving these questions you are not allowed to use any
Search Engine like Google, Yahoo, Bing …

All the best for your test

Globussoft
Question: - 1
Find a place to build a bridge over the river, so as to minimize total cost of the route between two
cities A and B, located on opposite sides of the river.

Input
There is a single positive integer T on the first line of input (equal to about 100000). It stands for
the number of test cases to follow. Each test case is exactly one line, containing six integers a, b, c,
h, s1 and s2 (0 < a, b, c, h, s1, s2 < 100), separated by spaces. a - the distance from city A to the
river (the length of segment AE in the figure), b - the distance from city B to the river (the length of
segment FG in the figure), c - the distance between A and B along the axis parallel to the river (the
length of segment BF in the figure) and h - the width of the river (EG in the figure). s1 and s2 are
the costs of unit of road and bridge respectively.

Output
For each test case your program should write a single number to the standard output, equal to the
minimal total cost of the route between A and B, accurate up to two digits after the decimal dot.

Example:

Input:

1
111111
Output:

3.16

Question: - 2
Run-length encoding of a number replaces a run of digits (that is, a sequence of consecutive
equivalent digits) with the number of digits followed by the digit itself. For example, 44455 would
become 3425 (three fours, two fives). Note that run-length encoding does not necessarily shorten
the length of the data: 11 becomes 21, and 42 becomes 1412. If a number has more than nine
consecutive digits of the same type, the encoding is done greedily: each run grabs as many digits
as it can, so 111111111111111 is encoded as 9161.

Implement an integer arithmetic calculator that takes operands and gives results in run-length
format. You should support addition, subtraction, multiplication, and division. You won't have to
divide by zero or deal with negative numbers.

Input/Output
The input will consist of several test cases, one per line. For each test case, compute the run-length
mathematics expression and output the original expression and the result, as shown in the
examples. The (decimal) representation of all operands and results will fit in signed 64-bit
integers.

Example:

Input:

11 + 11
988726 - 978625
12 * 41
1124 / 1112
13 * 33
15 / 16

Output:

11 + 11 = 12
988726 - 978625 = 919111
12 * 41 = 42
1124 / 1112 = 1112
13 * 33 = 39
15 / 16 = 10

Question: - 3
This is a problem to test the robustness of your Integer Factorization algorithm.
Given some integers, you need to factor them into product of prime numbers.
The largest integer given in the input file has 15 digits. FACT1 is a harder version of this problem
(the numbers are larger).

You may need to use a general factorization algorithm since no special numbers (e.g. Fermat
numbers) are considered when designing the input data.

Input
There are several numbers given, each one in a line.
The input ends with a number 0.
The number of test cases is about 10.

Output

For each number, print in a line the factorization of it. See examples below for the output format.

Example:

Input:

3111989
13091989
77145199750673
0

Output:

317^1 9817^1
17^2 89^1 509^1
328439^1 234884407^1
Question: - 4

According to Wikipedia, "The Traveling Salesman Problem (TSP) is a problem in combinatorial


optimization studied in operations research and theoretical computer science. Given a list of cities
and their pairwise distances, the task is to find a shortest possible tour that visits each city exactly
once. The problem was first formulated as a mathematical problem in 1930 and is one of the most
intensively studied problems in optimization. It is used as a benchmark for many optimization
methods. Even though the problem is computationally difficult, a large number of heuristics and
exact methods are known, so that some instances with tens of thousands of cities can be solved."
Fortunately, you won't have to solve TSP. You're working for a very clever traveling salesman who
has already figured out the path he is going to take. All he needs from you is a quick way to figure
out how far he traveled after every segment of his tour.

Input
The salesman kept detailed records of his travels. You'll be getting a series of lines of the form
"Some text (X, Y)." indicating that the salesman has been at the point X kilometers east and Y
kilometers north of the origin of a Cartesian plane.

Output
For each segment of the trip, output the total distance traveled up to that point as a line in the
format "The salesman has traveled a total of D kilometers." Show three digits after the decimal
point when printing D. Note that the salesman only travels in straight lines (even after a couple of
drinks).

Example:

Input:

I started out at (0, 5).


Then I traveled to (3.7, 5).
After a couple of drinks I wobbled to (2.7, 4).
The next morning I woke up near (4, 3).
I finished my journey in (-.2, 8).

Output:
The salesman has traveled a total of 3.700 kilometers.
The salesman has traveled a total of 5.114 kilometers.
The salesman has traveled a total of 6.754 kilometers.
The salesman has traveled a total of 13.284 kilometers.
Question: -5
A Byteotian ant is walking along the edges of ABCDEFGH cube:

It tries to find out, in how many ways it can go from one given vertex, to another given vertex,
walking along exactly k edges (when the ant enters an edge, it will not turn back and will finally
reach the second end of this edge). If the ant goes through some edge x times, we count this
edge x times. The ant would like to have interesting routes, that is if the ant is in some vertex, it
would like to leave this vertex using an edge other than the edge recently used to enter this vertex
(i.e. it want not to use the same edge twice in a row).

Our ant is not so smart, because it can only count using integers from 0 to p-1, for some p, so you
should compute the result modulo p.

Request

Write a program which:


 reads the starting and the ending vertex of the ant's route, number of edges on the ant's
route, and integer p,
 computes number of interesting routes, which satisfy the ant's requests, modulo p,
 writes the answer to the standard output.

Input
The first line of the standard input contains two capital English letters v1 and v2, separated by a
single space. The two letters denote the starting and ending vertex of the ant's route respectively.
The second line contains two integers k and p, separated by a single space.

Output
Exactly one integer is to be written on the standard output. This integer is the number of
interesting routes from the vertex v1 to the vertex v2, containing exactly k edges, modulo p.
Example:

Input:

AB
3 100

Output:

You might also like