359B. Permutation
生活随笔
收集整理的這篇文章主要介紹了
359B. Permutation
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
B. Permutation:題目
很容易就發現,按順序正好等于0。把i和i+2換一次可以加2,所以k是多少就換幾次 #include <bits/stdc++.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c[(int)6e5]; const int mod = 1e9 + 7; signed main() {int n, k;cin >> n >> k;for (int i = 1; i <= n * 2; i++)a[i] = i;for (int i = 2; i <= n * 2; i += 4){if (k == 0)break;swap(a[i], a[i + 2]);k--;}for (int i = 1; i <= n * 2; i++)cout << a[i] << " "; }總結
以上是生活随笔為你收集整理的359B. Permutation的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【SDK】极光推送
- 下一篇: 复旦计算机学院软件工程,2019年复旦9