题目链接: codeforces 1405A. Permutation Forgery
题意:
给出一个数组,数组相邻两个元素相加,得到一个新数组,进行排序。 现在需要对数组重新排序,找到一个相同的新数组。
6 2 1 6 5 4 3
F(p) = sort([2+1, 1+6 , 6+5 , 5+4, 4+3] ) = sort([3,7,11,9,7]) = [3,7,7,9,11]
解题思路:
只需将数组翻转即可,因为最后的数据是进行排序的
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int main(){
int t;
cin >> t;
while(t--) {
int n;
cin >> n;
int a[105];
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
for(int i = n; i >= 1; i--) {
cout << a[i] << " ";
}
cout << endl;
}
return 0;
}