Codeforces 264A Buggy Sorting(童年排序)
2016-12-13 10:31
211 查看
A. Buggy Sorting
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in
the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of the program gets number n and
array a.
loop integer variable i from 1 to n - 1 loop integer variable j from i to n - 1 if (aj > aj + 1), then swap the values of elements aj and aj + 1
But Valera could have made a mistake, because he hasn't yet fully learned the sorting algorithm. If Valera made a mistake in his program, you need to give a counter-example that makes his program work improperly (that is, the example that makes the program
sort the array not in the non-decreasing order). If such example for the given value of n doesn't exist, print -1.
Input
You've got a single integer n (1 ≤ n ≤ 50) —
the size of the sorted array.
Output
Print n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 100)
— the counter-example, for which Valera's algorithm won't work correctly. If the counter-example that meets the described conditions is impossible to give, print -1.
If there are several counter-examples, consisting of n numbers, you are allowed to print any of them.
Examples
input
1
output
-1
题意:
给小明的程序找 bug 就是 heak吗?思路:
其实真的没怎么看懂题目,自己英语和理解能力渣渣了。直接看代码->AC CODE:
#include<stdio.h>#include<cstring>
#include<algorithm>
#define HardBoy main()
#define ForMyLove return 0;
using namespace std;
const int MYDD = 1103;
int HardBoy {
int n;
scanf("%d", &n);
if(n <= 2) puts("-1");
else{
while(n) {
printf("%d ", n--);
}
}
printf("\n");
ForMyLove
}
相关文章推荐
- Codeforces 70D 动态凸包 (极角排序 or 水平序)
- Codeforces_352B_Jeff and Periods(排序)
- CodeForces 22D Segments 排序水题
- Codeforces 484B Maximum Value(排序+二分)
- Codeforces 556D Case of Fugitive【排序+贪心】
- Codeforces_350A_TL(排序)
- CodeForces 593B Anton and Lines【数学+排序】
- codeforces 632C The Smallest String Concatenation 排序
- CodeForces 382C Arithmetic Progression (排序+分类讨论)
- Codeforces 417D Cunning Gena【排序+状压dp】
- CodeForces 659 B. Qualifying Contest(结构体排序的问题)
- codeforces 484 B Maximum Value 排序+二分 + 数学
- 算法训练 Beaver's Calculator/codeforces 207A1 排序+贪心
- 模拟赛#1补题 CodeForces 580B(排序+二分)
- Codeforces - 558A. Lala Land and Apple Trees 排序
- CodeForces 719B Anatoly and Cockroaches(小强排序)
- 树状数组模拟3个元素的排序 Codeforces 12D Ball
- CodeForces - 257C View Angle 【极角排序】
- codeforces_612D. The Union of k-Segments(排序)
- Codeforces 12D Ball 树状数组模拟3个元素的排序