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

谁是你的潜在朋友

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

#include <iostream>
using namespace std;
#define MAXSIZE 1000
int main() {
    int n, m;
    int reader[MAXSIZE], frend[MAXSIZE];
    while (cin >> n >> m) { // 注意 while 处理多个 case
        for(int i=0; i<n; i++)
            cin>>reader[i];
       
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++)
                if(reader[i]==reader[j])
                    frend[i]+=1;
            frend[i]-=1;
        }
        for(int i=0; i<n; i++)
            if(frend[i])
                cout<<frend[i]<<endl;
            else
                cout<<"BeiJu"<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

牛客38347925...:9,2学生暑期实习失利开始投小厂,给这群人整自信了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务