1 条题解
-
1养猪场场长zms (njnu19210436) LV 9 MOD @ 2021-12-16 00:59:11
#include <bits/stdc++.h> using namespace std; #define N 10000 typedef struct node { int flag; struct node* next; }Node; typedef struct ysf { int flag; struct ysf* next; }Ysf; Node* Create_node(int n) { Node* head = new Node; Node* cycle = NULL; head->flag = 1; head->next = NULL; cycle = head; for (int i = 2; i <= n; i++) { Node* p = new Node; p->flag = i; p->next = NULL; cycle->next = p; cycle = cycle->next; } cycle->next = head; return head; } Node* Create_ysf(int arr[], int r) { Node* head = new Node; Node* cycle = NULL; head->flag = arr[0]; head->next = NULL; cycle = head; for (int i = 1; i < r; i++) { Node* p = new Node; p->flag = arr[i]; p->next = NULL; cycle->next = p; cycle = cycle->next; } cycle->next = head; return head; } int n, m, arr[N]; void Output() { cin >> n >> m; Node* a = Create_node(n); for (int i = 0; i < m; i++) cin >> arr[i]; Node* b = Create_ysf(arr, m); int t = 1; while (n > 1) { if (a->flag == 0) a = a->next; else { if (t == b->flag) { t = 1; a->flag = 0; b = b->next; a = a->next; n--; } else { t++; a = a->next; } } } while (a->flag == 0) { a = a->next; } cout << a->flag << endl; } int main() { Output(); return 0; }
- 1
信息
- ID
- 2915
- 难度
- 9
- 分类
- (无)
- 标签
- 递交数
- 3
- 已通过
- 1
- 通过率
- 33%
- 上传者