Professional Documents
Culture Documents
Codevita - 22-07-2017
Codevita - 22-07-2017
Codevita - 22-07-2017
Input
Output
Example 1
Input:
0,0,1,1,3,5,6,7,7
Output:
11:57:37
Example 2
Input:
3,3,3,3,3,3,3,3,3
Output:
Impossible
No set of six digits from the input may be used to form a valid
time.
Input
Output
One integer M giving the number of primes P such that N1 <= P <=
N2 that are such that when P is written in words, it has a prime
number of letters.
Constraint
N2 <= 99999
Example 1
Input:
1 10
Output:
3
Explanation:
The primes between 1 and 10 and 2, 3, 5 and 7. Of these, 5
written in words is FIVE and has a non prime number of letters
and others have prime number of letters (viz TWO, THREE and
SEVEN).
Example 2
Input:
1100 1130
Output:
1
Explanation:
The primes between 1100 and 1130 are 1103, 1109, 1117, 1123 and
1129. When these are written in words, we get
ONE THOUSAND ONE HUNDRED AND THREE
ONE THOUSAND ONE HUNDRED AND NINE
ONE THOUSAND ONE HUNDRED AND SEVENTEEN
ONE THOUSAND ONE HUNDRED AND TWENTY THREE
ONE THOUSAND ONE HUNDRED AND TWENTY NINE
The count of characters in the above are 29, 28, 33, 35 and 34
Of these only for 1103 the count of characters is prime.
Input
The input is a positive integer N
Output
The number of factors of the even side of the smallest FRAT which
has an odd hypotenuse greater than N
Constraints
Example 1
Input:
10
Output:
6
Explanation:
The smallest FRAT that has an hypotenuse greater than 10 is
(13,12,5). As the hypotenuse is odd, we take this. The even side
is 12, factors are (1,2,3,4,6,12), a total of 6 factors. The
output is 6
Example 2
Input:
20
Output:
10
Explanation:
The smallest FRAT that has an hypotenuse greater than 20 is
(34,30,16). As the hypotenuse is even, we take the next FRAT,
which is (89,80,39). The even side is 80, factors are
(1,2,4,5,8,10,16,20,40,80), a total of 10 factors. The output is
10
Input
Output
Constraints
1N1000000000000
1d1000000
Example 1
Input
210
2
Output
12
Example 2
Input
1707693158
853684
Output
513917768
Example 3
Input
531
2
Output
-1
Explanation
1. In first test case the minimum number formed using all the
three digits divisible by the given divisor is 012 which is
equivalent to 12 and this is a multiple of d = 2. Hence the
output is 12.
2. In second test case the minimum number formed using all the
digits divisible by the given divisor is 0513917768. So in this
case the output will be 513917768.
3. In the last case all permutations of digits of N are odd and
hence not divisible by d.
TCS India has developed a funny and entertaining game. When you
begin, the screen contains a number of lines. An enemy plane
drops a bomb of certain radius R at a certain location (x,y) on
the screen and all the portions of the lines that are within a
circle of
After the bomb destroys the portions of the lines, compute the
sum of the lengths of the lines remaining.
Input
The third line contains the coordinates of the point at which the
bomb is dropped, as a pair of space separated integers (x and y)
The next N input lines contain the coordinates of the start and
the end of a line on the screen. This is a set of 4 space
separated integers (may be negative or 0) representing the x and
y coordinates of the starting and ending point respectively of
the line on the screen.
Output
Constraints
1<N<20
-1000<x,y coordinates of lines, bomb drop <1000
0<r<1000
Example 1
Input:
4
4
2 4
2 6 2 12
2 -10 2 -6
4 4 10 4
-8 4 -4 4
Output:
16.00
Explanation:
Before the bomb drop, the lines on the screen were as follows
Example 2
Input:
7
4
3 5
3 9 3 13
3 -3 3 -15
4 9 16 9
-1 9 -11 9
11 13 3 5
9 8 4 6
-1 5 -5 5
Output:
52.04
Explanation:
There are initially 7 lines, and the bomb is dropped at (3,5)
with a radius 4. Only the fifth and sixth lines are affected by
the bomb, and become 7.31 and 2.72 in length. The total residual
length (correct to two decimals is 52.04, which is the output.
The class had been taught programming in the summer, and so some
students quickly wrote some code to count the squares, and Mr
Smith did not get much sleep !
Input
Output
Constraints
4N20
0m40
IN
J(N-1)
Example 1
Input
4
4
H,2,1
H,3,1
V,2,2
V,2,3
Output
5
Explanation
There are 4 vertical and horizontal lines, and 4 line segments
missing. The first missing horizontal segment is on the second
horizontal line, between the first and second point, and the
other missing horizontal segment is on the third horizontal line
at the same position. The two missing vertical segments are on
the second vertical line, and between the second and third, and
the third and fourth points respectively.
It can be seen that this describes the above figure. There is one
3 x 3 square, zero 2 x 2 squares and four 1 x 1 squares, a total
of 5 squares. Hence the output is 5.
Example 2
Input
4
2
V,2,2
V,2,3
Output
8
Explanation