Gaby Ivanushka

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
 #include <stdio.h>
long c;
long A[N]; long P(long l, long r)
{
long x=A[l],
i=l-1,
j=r+1,
t;
while(1)
{
do{--j; ++c;}
while(A[j]>x);
do{++i; ++c;}
while(A[i]<x);
if(i<j)
{
t=A[i];
A[i]=A[j];
A[j]=t;
}
else return j;
}
} void Q(long l, long r)
{
long n;
if(l<r)
{
n=P(l,r);
Q(l,n);
Q(n+1,r);
}
} int main(void)
{
c=0;
for(long i=0; i<N; ++i)
scanf("%ld", &A[i]);
Q(0,N-1);
if(c==(N*N+3*N-4)/2)
printf
("Beutiful Vasilisa");
else printf
("Immortal Koshcei");
return 0;
}
 var A:array [1..N] of
longint;
c:longint;
i:integer;
function
P(l,r:longint):longint;
var i,j,t,x:longint;
begin
x:=A[l]; i:=l-1; j:=r+1;
while true do
begin
repeat dec(j);inc(c)
until A[j]<=x;
repeat inc(i);inc(c)
until A[i]>=x;
if i<j then
begin
t:=A[i];
A[i]:=A[j];
A[j]:=t
end
else
begin P:=j; exit end
end
end; procedure Q(l,r:longint);
var n:longint;
begin
if l<r then
begin
n:=P(l,r);
Q(l,n);
Q(n+1,r)
end
end; begin
c:=0;
for i:=1 to N do
read(A[i]);
Q(1,N);
if c=(N*N+3*N-4) div 2
then
writeln
('Beutiful Vasilisa')
else writeln
('Immortal Koshcei');
end.
Now you know this program. You may try to help Ivanushka.

Input

The first line of an input contains a positive number N ≤ 1000.

Output

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.

Example

input output
3
3 7 19

//代码就是快排。

输出一个等差数列即可

  #include <stdio.h>
int main()
{
int n;
while (scanf("%d",&n)!=EOF)
{
int i;
for (i=;i<n;i++)
printf("%d ",i);
printf("%d\n",i);
}
}

最新文章

  1. Linux &amp; Systemd 挂载问题解决
  2. Quartz.NET总结(一)入门
  3. POJ 2411 Mondriaan&amp;#39;s Dream
  4. windows all version - 实现指定路径共享
  5. 运行最快的安卓模拟器VirtualBox安装教程
  6. Microsoft.SharePoint.Security的问题
  7. grunt--自动化打包工具使用
  8. InstallShield -6109
  9. .net core 依赖注入扩展,实现随处控制反转
  10. ansible源码安装
  11. MySQL分支Percona
  12. Gym - 100971J (思维+简单bfs)
  13. MFC坐标转换
  14. Android (Android Studio)无法启动adb 解决方案
  15. C#简单窗体应用程序(二)
  16. angularJS1笔记-(12)-自定义指令(compile/link)
  17. [LeetCode 题解]: Linked List Cycle II
  18. System.Web.Caching.Cache类 缓存 各种缓存依赖(转)
  19. JavaScript学习记录总结(八)——全选、反选
  20. zigbee之MAC地址发送

热门文章

  1. ylb:事务处理
  2. JAVA之接口与抽象类区别
  3. phpMyAdmin搭建及管理多台数据库服务器
  4. 2017.7.10 (windows)redis的安装
  5. iOS学习笔记之蓝牙(有关蓝牙设备mac地址处理)
  6. 微信小程序 - 获取用户信息的几种方式
  7. 类的成员函数指针和mem_fun适配器的用法
  8. Linux组件封装(五)一个生产者消费者问题示例
  9. POJ2536 Gopher II【二分图最大匹配】
  10. 自定义ListView和GridView