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