题目描述
blablabla
样例
#include<iostream>
//因为要应对机试所以就不能用C++里的函数 显得繁琐
using namespace std;
int n, k;
int add;
int p[1010];
void shift(int n, int p[], int add){
int q[1010];
for(int i = 0; i < n; i ++){
q[i] = p[i];
}
int move = n - add;
//cout << move << "\n";
//cout << "+ ";
for(int i = 0; i < n; i ++){
p[(i + move) % n] = q[i];
//cout << p[(i + move) % n] << " ";
}
// cout << "\n+ ";
//for(int i = 0; i < n; i ++) cout << p[i] << " ";
//cout << "\n";
}
void flip(int n, int p[]){
int q[1010];
for(int i = 0; i < n; i ++){
q[i] = p[i];
}
int m = n / 2;
// cout << "- ";
for(int i = m - 1; i >= 0; i --){
p[m - i - 1] = q[i];
//cout << p[m - i -1] << " ";
}
//cout << "\n";
}
int main(){
cin >> n >> k;
for(int u = 0; u < n; u ++) p[u] = u + 1;
for(int i = 0; i < k; i ++){
cin >> add;
shift(n, p, add);
flip(n, p);
}
for(int j = 0; j < n; j ++){
cout << p[j] << " ";
}
cout << "\n";
}
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla