A - Special Numbers: Problem Code: BONUMBER
A - Special Numbers: Problem Code: BONUMBER
A - Special Numbers
Problem code: BONUMBER
Problem A
Special Numbers
Every person has its own special numbers that he considers lucky. Usually the numbers
are fixed like 3 or 7 and do not depend on anything. This lucky number model seems to
be very primitive for John, so he decided to upgrade it for his own use. Maybe more
complex model will bring more luck to him?
John has added a dependency for lucky numbers on specific integer N (for example N
can be ordinal number of day in year or some other meaning). For each N John considers
some number X lucky if and only if fraction X/√N−X value is integer and greater than
zero.
INPUT
The number of tests T (T ≤ 100) is given on the first line. T lines follow, each of them
contains one integer N (1 ≤ N ≤ 109) described above.
OUTPUT
For each test case output a single line "Case T: S". Where T is the test case number
(starting from 1) and S is increasing sequence of numbers considered lucky by John for
specified N. Please refer to the sample output for clarity.
SAMPLE INPUT
3
16
109
33
SAMPLE OUTPUT
Case 1: 12 15
Case 2: 108
Case 3: 24 32
8771. B - CLocK
Problem code: BOCLOCK
Problem B
CLocK
Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing
from machine guns or radiation mutants time-travels!
There was a beauty named Belle. Once she had violated the Beast's order and visited the
West Wing. After that she was banished from the castle...
Everybody was upset. The beautiful Belle was upset, so was the Beast, so was Lumiere
the candlestick. But the worst thing was that Cogsworth was upset. Cogsworth is not a
human, but is the mantel clock, which was often used as an alarm clock.
Due to Cogsworth's frustration all the inhabitants of the castle were in trouble: now they
could not determine when it was time to drink morning tea, and when it was time for an
evening stroll.
Fortunately, deep in the basement are lying digital clock showing the time in the format
HH:MM. Now the residents of the castle face a difficult task. They should turn
Cogsworth's hour and minute mustache hands in such a way (i.e. clockwise direction),
that Cogsworth began to show the correct time. Moreover they need to find turn angles
in degrees for each mustache hands. The initial time showed by Cogsworth is 12:00.
As since there are many ways too select such angles because of full rotations, choose
the smallest angles in the right (non-negative) direction.
Input
The only line of input contains current time according to the digital clock, formatted as
HH:MM (00 ≤ HH ≤ 23, 00 ≤ MM ≤ 59). The mantel clock initially shows 12:00.
Pretests contain times of the beginning of some morning TV programs of the Channel
One Russia.
Output
Print two numbers x and y — the angles of turning the hour and minute hands,
respectively (0 ≤ x, y < 360). The absolute or relative error in the answer should not
exceed 10 - 9.
Sample Input Sample Output
12:00 00
Note.- A note to the second example: the hour hand will be positioned exactly in the
middle, between 4 and 5.
8772. C - GCD Reloaded
Problem code: BOGCDRE
Problem C
GCD RELOADED
Well, here is another math class task. In mathematics, GCD is the greatest common
divisor, and it's an easy task to calculate the GCD between two positive integers.
A common divisor for two positive numbers is a number which both numbers are
divisible by.
But your teacher wants to give you a harder task, in this task you have to find the
greatest common divisor d between two integers a and b that is in a given range from
low to high (inclusive), i.e. low ≤ d ≤ high. It is possible that there is no common divisor
in the given range.
You will be given the two integers a and b, then n queries. Each query is a range from
low to high and you have to answer each query.
Input
The first line contains two integers a and b, the two integers as described above
(1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries
(1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two
integers, low and high (1 ≤ low ≤ high ≤ 109).
Output
Print n lines. The i-th of them should contain the result of the i-th query in the input. If
there is no common divisor in the given range for any query, you should print -1 as a
result for this query.
3 -1
1 5 9
10 11
Sample Input Sample Output
9 11
8773. D - SUMXOR
Problem code: BOSUMXOR
Problem D
SUMXOR
Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is
equivalent to applying logical exclusive OR to every pair of bits located on the same
positions in binary notation of operands. In other words, a binary digit of the result is
equal to 1 if and only if bits on the respective positions in the operands are different.
Write a program, which takes two non-negative integers A and B as an input and finds
two non-negative integers X and Y, which satisfy the following conditions:
A = X + Y
B = X xor Y, where xor is bitwise exclusive or.
X is the smallest number among all numbers for which the first two conditions
are true.
Input
The first line contains integer number A and the second line contains integer number B
(0 ≤ A, B ≤ 264 - 1).
Output
The only output line should contain two integer non-negative numbers X and Y. Print
the only number -1 if there is no answer.
76
8774. E - Bolivia Football Federation
Problem code: BOSOCCER
Problem E
The Bolivia football team coach, Gustavo Quinteros, is going to try out a new formation
this year. Formation describes how the players are positioned on the pitch. Instead of
the conventional 4-4-2 or 4-3-3, he has opted for 5-5. This means there are 5 attackers
and 5 defenders.
You have been hired by Bolivia Football Federation (FBF) to write a code that will
help them figure out which players should take the attacking/defensive positions.
Quinteros has given you a list containing the names of the 10 players who will take the
field. The attacking ability and the defensive ability of each player are also given. Your
job is to figure out which 5 players should take the attacking positions and which 5
should take the defensive positions.
Input
The first line of input contains an integer T(T<50) that indicates the number of test
cases. Each case contains exactly 10 lines. The ith line contains the name of the ith
player followed by the attacking and defending ability of that player respectively. The
length of a player’s name is at most 20 and consists of lowercase letters only. The
attacking/defending abilities are integers in the range [0, 99].
Output
The output of each case contains three lines. The first line is the case number starting
from 1. The next line contains the name of the 5 attackers in the format (A1, A2, A3, A4,
A5) where Ai is the name of an attacker. The next line contains the name of the 5
defenders in the same format. The attackers and defenders names should be printed in
lexicographically ascending order. Look at the sample for more details.
jaan 17 86
sidky 16 36
shamim 16 18
shadowcoder 12 9
muntasir 13 4
brokenarrow 16 16
emotionalblind 16 12
tanaeem 20 97
8775. F - GCD Again
Problem code: BOGCDAGA
Problem F
GCD Again
Given the N integers, you have to find the maximum GCD(greatest common divisor) of
every possible pair of these integers.
Input
The first line of input is an integer N(1<N<100) that determines the number of test
cases.
The following N lines are the N test cases. Each test case contains M (1<M<100)
positive integers that you have to find the maximum of GCD.
Output
For each test case show the maximum GCD of every possible pair.