codeforces Round #668 (Div. 2) 1405A Permutation Forgery

Topic link

Insert picture description here

Title translation:

A permutation of length n is an array composed of integers 1~n in random order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice), and [1,3,4] is not a permutation (n=3 but 4 in the array).
p is a permutation of length n. We define fingerprint F(p) as an ordered array composed of the sum of any two adjacent elements of the array p, namely F(p)=sort([p 1 +p 2 , p 2 +p 3 ,…, p n-1 +p n ]) .
For example, if n=4 and p=[1,4,2,3], then F(p) = sort([1+4,4+2,2+3]) = sort([5,6,5 ]) = [5,5,6].
To give you a length n Permutation P , your task is to find a different Permutation P ' , so that ** F (p) and F (p') ** equal. If p I ! = P ' I indicates p and p' are two different permutation.

Problem-solving ideas:

It took me 17 minutes to write too few questions, and I finally found out that the output in reverse order would do.

Code:
#include<iostream>
using namespace std;
int main(){
    
    
//	freopen("1.txt","r",stdin);
	int t,n,a[110];
	cin>>t;
	while(t--){
    
    
		cin>>n;
		for(int i=0;i<n;i++){
    
    
			cin>>a[i];
		}
		for(int i=n-1;i>=0;i--){
    
    
			cout<<a[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}
to sum up:

Think more, like this question is really simple, but I can't think of it at first, but after looking at the score, I found that it was less than 500, so I thought about it simple.

Guess you like

Origin blog.csdn.net/lmmmmmmmmmmmmmmm/article/details/108463088