Problems |
![]() |
1. "THE FAMOUS FOUR"
Let us denote by K5 a collection of five decimal digits (There can be several equal digits in the collection).
Let us say that a five-digit integer is made specifically from K5, if the decimal notation of this number is obtained from K5 digits writing sequently all of them (each digit must be used only once), and this notation does not begin with 0.
For example, if K5 contains digits 1,1,7,0 and 4, then numbers 17140 and 47011 are made specifically from K5, but 17740 isn't.
Let us say that four natural numbers s1,s2,s3,s4
is the K5 famous four, if at the same
time the following conditions are true :
1) s1 is made specifically from K5;
2) s2 is made specifically from K5;
3) s3 is made specifically from K5;
4) s4 is made specifically from K5;
5) there are no two equal numbers among s1,
s2, s3 and s4;
6) s1+ s2 + s3 =
s4
You have to - for the given five digits of K5
determine how many different K5 famous
four's exist. (It is not possible to obtain another famous four
if just the order of numbers inside one four is changed).
Examples
Input data | Output data | Comment |
0 2 6 2 8 | 4 | 26028+26208+28026=80262
26082+26280+28260=80622 26028+28026+28206=82260 26280+28062+28260=82602 |
Input data | Output data | |
9 2 3 3 9 | 0 |
2. "TRAVEL WITH A KNIGHT"
The dimensions of the squared rectangular board is
n*m squares. In the bottom left square of the board (1;1)
there is a chess knight (see Figure 1).
A knight can make moves only according to chess rules
- a move can be two squares horisontaly and then one verticaly,
or two squares verticaly and then one horisontaly.
For example, if n=4 and m=3 and the knight is in
the square (2;1) (see Figure 2), then the next move can be only
to one of the following squares: (1;3),(3;3) or (4;2).
For the given positive integer values n,m,i,j
(n<=100,m<=100,i<=n,j<=m) you must determine and output
the least necessary number of the knight's moves to come
from the initial state (1;1) to the square (i;j).
If it is not possible to come to this square, you
must output "NEVAR". Examples
|
|
3. "BILLIARDS"
There is a rectangular board of dimensions 47*73
centimeters. Its edges are denoted by A,R,Z,D. A ball (which is
like a point) B is 13 centimeters from the edge R and 29 centimeters
from the edge D (see Figure 3). On the edge R at the point which
is k centimeters from the edge D a player place the cue
and reaches the ball B with a stright direction strike.
The ball moves straight forward all the time, perhaps
rebounding from the edges (according to common laws of physics).
The fragment of ball's movement trace is shown in the figure 4.
You are to write a program which for the given integer
values k(0<=k<=73) and n(0<=n<109)
determines and writes the distance to the edge R (BR)
and the edge D (BD) after the ball has moved exactly
n centimeters. The values of BR and BD
must contain at least 3 correct digits after decimal point.
Examples
|
|