【題解】Codeforces 1205A. Almost Equal

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

#include <iostream>
using namespace std;
 
int n, ans[200005];
 
int main() {
    cin >> n;
    if (n % 2 == 0) cout << "NO\n";
    else {
        cout << "YES\n";
        for (int i = 1; i <= n; i++){
            if (i % 2 == 0) cout << i*2 << " ";
            else cout << i*2-1 << " ";
        }
        for (int i = 0; i < n; i++){
            if (i % 2 == 0) cout << i*2+2 << " ";
            else cout << i*2+1 << " ";
        }
        cout << "\n";
    }
}
分享本文 Share with friends