Questions
Questions
Questions
Globussoft
Question: - 1
Given the length of side a of a triangle and the distances from the centroid (the point of
concurrence of the medians - red in the picture) to all sides: a, b and c, calculate this triangle's
area and the distance (blue line) from the orthocenter (the point of concurrence of the
heights - green in the picture) to the centroid.
Input
In the first line integer n - the number of test cases (equal to about 1000). The next n lines -
4 floating point values: the length of side a, and distances from the centroid to sides a, b and
c.
Output
n lines consisting of 2 floating point values with 3 digits after the decimal point: the area of
the triangle and the distance from the orthocenter to centroid.
Example:
Input
2
3.0 0.8660254038 0.8660254038 0.8660254038
657.8256599140 151.6154399062 213.5392629932 139.4878846649
Output
3.897 0.000
149604.790 150.275
Question: - 2
n one of the internet banks thousands of operations are being performed every day. Since
certain customers do business more actively than others, some of the bank accounts occur
many times in the list of operations. Your task is to sort the bank account numbers in
ascending order. If an account appears twice or more in the list, write the number of
repetitions just after the account number. The format of accounts is as follows: 2control
digits, an 8-digit code of the bank, 16 digits identifying the owner (written in groups of four
digits), for example (at the end of each line there is exactly one space):
Banks are real-time institutions and they need FAST solutions. If you feel you can meet the
challenge within a very stringent time limit, go ahead! A well designed sorting algorithm in
a fast language is likely to succeed.
Input
t [the number of tests <= 5]
n [the number of accounts<= 100 000]
[list of accounts]
[empty line]
[next test cases]
Output
[sorted list of accounts with the number of repeated accounts]
[empty line]
[other results]
Example:
Input
2
6
03 10103538 2222 1233 6160 0142
03 10103538 2222 1233 6160 0141
30 10103538 2222 1233 6160 0141
30 10103538 2222 1233 6160 0142
30 10103538 2222 1233 6160 0141
30 10103538 2222 1233 6160 0142
5
30 10103538 2222 1233 6160 0144
30 10103538 2222 1233 6160 0142
30 10103538 2222 1233 6160 0145
30 10103538 2222 1233 6160 0146
30 10103538 2222 1233 6160 0143
Output
03 10103538 2222 1233 6160 0141 1
03 10103538 2222 1233 6160 0142 1
30 10103538 2222 1233 6160 0141 2
30 10103538 2222 1233 6160 0142 2
Question: - 3
Let N be a positive integer and d(N) be the number of positive divisors of N including 1 and
N. Your task is to compute all N in [1,10^6] for which d(N)>3 and if M divides N then d(M)
divides d(N) too.
Input
None.
Output
To make the problem less output related write out only every 108-th of them, one per line.
Example:
Input
None.
Output
267
511
753
...
999579
999781
999977
Question: - 4
It’s preseason and the local newspaper wants to publish a preseason ranking of the teams in
the local amateur basketball league. The teams are the Ants, the Buckets, the Cats, the
Dribblers, and the Elephants. When Scoop McGee, sports editor of the paper, gets the
rankings from the selected local experts down at the hardware store, he’s dismayed to find
that there doesn’t appear to be total agreement and so he’s wondering what ranking to
publish that would most accurately re ect the rankings he got from the experts. He’s found
that finding the median ranking from among all possible rankings is one way to go.
The median ranking is computed as follows: Given any two rankings, for instance ACDBE and
ABCDE, the distance between the two rankings is defined as the total number of pairs of
teams that are given different relative orderings. In our example, the pair B, C is given a
different ordering by the two rankings. (The first ranking has C above B while the second
ranking has the opposite.) The only other pair that the two rankings disagree on is B, D; thus,
the distance between these two rankings is 2. The median ranking of a set of rankings is that
ranking whose sum of distances to all the given rankings is minimal. (Note we could have
more than one median ranking.) The median ranking may or may not be one of the given
rankings.
Suppose there are 4 voters that have given the rankings: ABDCE, BACDE, ABCED and ACBDE.
Consider two candidate median rankings ABCDE and CDEAB. The sum of distances from the
ranking ABCDE to the four voted rankings is 1 + 1 + 1 + 1 = 4. We’ll call this sum the value of
the ranking ABCDE. The value of the ranking CDEAB is 7 + 7+ 7 + 5 = 26. It turns out that
ABCDE is in fact the median ranking with a value of 4.
Input
There will be multiple input sets. Input for each set is a positive integer n on a line by itself,
followed by n lines (n no more than 100), each containing a permutation of the letters A, B,
C, D and E, left-justified with no spaces. The final input set is followed by a line containing a
0, indicating end of input.
Output
Output for each input set should be one line of the form:
Example:
Input
4
ABDCE
BACDE
ABCED
ACBDE
0
Output
ABCDE is the median ranking with value 4.
Question: - 5
It's Friday evening and Jill hates two things which are common to all trains:
They are always late.
The schedule is always wrong.
Nevertheless, tomorrow in the early morning hours Jill will have to travel from Hamburg to
Darmstadt in order to get to the regional programming contest. Since she is afraid of arriving
too late and being excluded from the contest she is looking for the train which gets her to
Darmstadt as early as possible. However, she dislikes to get to the station too early, so if there
are several schedules with the same arrival time then she will choose the one with the latest
departure time.
Jill asks you to help her with her problem. You are given a set of railroad schedules from
which you must compute the train with the earliest arrival time and the fastest connection
from one location to another. One good thing: Jill is very experienced in changing trains. She
can do this instantaneously, i.e., in zero time!!!
Input
The very first line of the input gives the number of scenarios. Each scenario consists of three
parts.
Part one lists the names of all cities connected by the railroads. It starts with a number 1
< C ≤ 100, followed by C lines containing city names. These names consist of letters.
Part two describes all the trains running during a day. It starts with a number T ≤
1000 followed by T train descriptions. Each of them consists of one line with a number ti ≤
100 and ti more lines with a time and a city name, meaning that passengers can get on or
off the train at that time at that city.
Part three consists of three lines: Line one contains the earliest journey's starting time,
line two the name of the city where she starts, and line three the destination city. The two
cities are always different.
Output
For each scenario print a line containing "Scenario i", where i is the number of the scenario
starting at 1.
If a connection exists then print the two lines containing zero padded timestamps and
locations as shown in the sample. Use blanks to achieve the indentation. If no connection
exists on the same day (i.e., arrival before midnight) then print a line containing "No
connection".
Input
2
3
Hamburg
Frankfurt
Darmstadt
3
2
0949 Hamburg
1006 Frankfurt
2
1325 Hamburg
1550 Darmstadt
2
1205 Frankfurt
1411 Darmstadt
0800
Hamburg
Darmstadt
2
Paris
Tokyo
1
2
0100 Paris
2300 Tokyo
0800
Paris
Tokyo
Output
Scenario 1
Departure 0949 Hamburg
Arrival 1411 Darmstadt
Scenario 2
No connection