def solve(n, a, k):
leader = 0
size = n
p = list(range(1, n+1))
res = []
for i in range(0, k):
j = (leader+a[i]) % size
res.append(p[j])
p.pop(j)
size -= 1
leader = j % size
print(*res)
def main():
n,k = map(int,input().split())
a = [int(x) for x in input().split()]
solve(n, a, k)
if __name__ == "__main__":
main()
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <ctime>
#include <string>
#include <cstring>
#define lowbit(x) x & (-x)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n, k, child[105];
queue <int> children;
int main() {
cin >> n >> k;
for (int i = 1; i <= k; i ++) {
cin >> child[i];
}
for (int i = 1; i <= n; i ++) {
children.push(i); //进队
}
for(int i = 1;i <= k;i++) {
child[i] %= children.size(); //防止循环次数过多,而TLE
for (int j = 1; j <= child[i]; j ++) {
children.push (children.front());
children.pop();
}
cout << children.front() << " ";
children.pop(); //出队
}
return 0;
}
1356. Sort Integers by The Number of 1 Bits | 922. Sort Array By Parity II |
344. Reverse String | 1047. Remove All Adjacent Duplicates In String |
977. Squares of a Sorted Array | 852. Peak Index in a Mountain Array |
461. Hamming Distance | 1748. Sum of Unique Elements |
897. Increasing Order Search Tree | 905. Sort Array By Parity |
1351. Count Negative Numbers in a Sorted Matrix | 617. Merge Two Binary Trees |
1450. Number of Students Doing Homework at a Given Time | 700. Search in a Binary Search Tree |
590. N-ary Tree Postorder Traversal | 589. N-ary Tree Preorder Traversal |
1299. Replace Elements with Greatest Element on Right Side | 1768. Merge Strings Alternately |
561. Array Partition I | 1374. Generate a String With Characters That Have Odd Counts |
1822. Sign of the Product of an Array | 1464. Maximum Product of Two Elements in an Array |
1323. Maximum 69 Number | 832. Flipping an Image |
1295. Find Numbers with Even Number of Digits | 1704. Determine if String Halves Are Alike |
1732. Find the Highest Altitude | 709. To Lower Case |
1688. Count of Matches in Tournament | 1684. Count the Number of Consistent Strings |