大年初三,cpu干烧了
#include <stdio.h> #define MAXN 201 int main() { int N, M; scanf("%d %d", &N, &M); int favorite_books[MAXN]; // 存储每个读者最喜欢的书的编号 int book_count[MAXN] = {0}; // 存储每本书被喜欢的读者数量 for (int i = 0; i < N; i++) { scanf("%d", &favorite_books[i]); book_count[favorite_books[i]]++; } for (int i = 0; i < N; i++) { int potential_friends = book_count[favorite_books[i]] - 1; if (potential_friends == 0) { printf("BeiJu\n"); } else { printf("%d\n", potential_friends); } } return 0; }评价是嵌套数组真是考验脑子捏