Once upon a time there lived a tsar that has a daughter — Beautiful Vasilisa. There
were many of the young men that wanted to marry her but she repelled all suitors. The
tsar was tired of her jigs, he got angry and issued an order: "The first who solves my
puzzle, will marry Vasilisa!"
Ivanushka decided to try his fortune. He came to the tsar and the tsar told him:
"This is a program for you. Input N numbers and the program will tell you who you
should marry. I give you a day to think."
Ivanuska looked at the program and got upset: there were unknown letters,
omnifarious symbols. The time passed. Ivanushka has thought out nothing.
The program was as follows.
|The C program||The Pascal program|
long P(long l, long r)
else return j;
void Q(long l, long r)
for(long i=0; i<N; ++i)
var A:array [1..N] of
x:=A[l]; i:=l-1; j:=r+1;
while true do
if i<j then
begin P:=j; exit end
if l<r then
for i:=1 to N do
if c=(N*N+3*N-4) div 2
Now you know this program. You may try to help Ivanushka.
The first line of an input contains a positive number N ≤ 1000.
You are to write to an output N numbers in one line. The tsar's program given
those numbers should output a message "Beautiful Vasilisa" The numbers should be
separated with a space. If several variants are possible choose any you like.
Problem Author: Nikita Shamgunov
Problem Source: The 3rd high school children programming contest, USU, Yekaterinburg, Russia, March 4, 2001