题解 | #谁是你的潜在朋友#

谁是你的潜在朋友

https://www.nowcoder.com/practice/0177394fb25b42b48657bc2b1c6f9fcc

//土尔逊Torson 编写于2023/06/14
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <map>

using namespace std;

int main() {
	int n, m;
	while (scanf("%d%d", &n, &m) != EOF) {
		map<int, int> bookFriend;
		map<int, int> bookCount;
		for (int i = 0; i < n; ++i) {
			int bookNum;
			scanf("%d", &bookNum);
			bookFriend[i] = bookNum;
			bookCount[bookNum]++;
		}
		for (int i = 0; i < n; ++i) {
			int bookKey = bookFriend[i];
			if (0 != bookCount[bookKey] - 1) {
				printf("%d\n", bookCount[bookKey] - 1);
			}
			else {
				printf("BeiJu\n");
			}
		}
	}
	system("pause");
	return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
秋盈丶:后续:我在宿舍群里和大学同学分享了这事儿,我好兄弟气不过把他挂到某脉上了,10w+阅读量几百条评论,直接干成精品贴子,爽
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务