#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, x, num;
while(cin >> n >> x)
{
vector<int> house;
for (int i=0; i<n; i++){
cin >> num;
house.push_back(num);
}
num = 0;
while (house[x-1]){
++num;
--house[x-1];
--x;
if(x == 0)
x = n;
}
house[x-1] = num;
for(int i=0; i<n; ++i)
cout << house[i] << " ";
cout << endl;
}
return 0;
}
今日头条笔试题
最新推荐文章于 2022-07-14 00:29:20 发布