编程介的小学生 2016-12-23 11:35 采纳率: 20.5%
浏览 981
已采纳

Perfect Permutation

A permutation of 1..n {An} is called a Perfect Permutation if the sequence {|Ai − i|} is a permutation of 0..(n − 1).

For example, {3, 2, 4, 1} is a perfect permutation for {2, 0, 1, 3} is a permutation of 0..3.

Given an integer n, your mission is to find a perfect permutation of 1..n.

输入描述

The input consists of several lines. Each line contains a positive integer n ≤ 1000.

输出描述

The output contains one line for each line in the input. If no such perfect permutation exists, output a single number 0 otherwise the perfect permutation. If more than one solution exist, you can output anyone.

输入例子

1

2

4

输出例子

1

0

3 2 4 1

  • 写回答

1条回答 默认 最新

  • devmiao 2016-12-23 16:50
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 6-3 String类定义
  • ¥15 嵌入式--定时器使用
  • ¥15 基于OPENCV的人脸识别
  • ¥20 51单片机学习中的问题
  • ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
  • ¥15 Python中knn问题
  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上