1.只管给出最终结果,题目中限制可忽视(的确是一种追求速度不太严谨的做法)
2.博主给出的这种写法如果不把m=0的情况单独考虑会导致一个样例不能通过
#include
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
int a[110];
for (int i=0; i < n; i++)
cin >> a[i];
m = m % n;
int i = n - m;
int num = 0;
if (m == 0)
{
for (int j = 0; j < n-1; j++)
cout<< a[j]<<' ';
cout << a[n - 1];
return 0;
}
while (num < n-1)
{
cout << a[i]<<' ';
i++;
i = i % n;
num++;
}
cout << a[n - m - 1];
return 0;
}