【題解】Codeforces 1435A. Finding Sasuke

【題目敘述】http://codeforces.com/contest/1435/problem/A

#include <bits/stdc++.h>
using namespace std;
 
int t, n, a[105];
 
int main(){
    cin >> t;
    while (t--){
        cin >> n;
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        for (int i = 0; i < n/2; i++){
            if (a[i] < 0) cout << abs(a[n-i-1]) << " ";
            else cout << -abs(a[n-i-1]) << " ";
        }
        for (int i = n/2; i < n; i++){
            if (a[i] < 0) cout << -abs(a[n-i-1]) << " ";
            else cout << abs(a[n-i-1]) << " ";
        }
        cout << "\n";
    }
}
分享本文 Share with friends