C++程序:新浪微博悄悄关注侦探 - 识别潜在的悄悄关注用户 日期: 2027-11-18 标签: 常规 #include\x20\n#include\x20\n#include\x20\n#include\x20\nusing\x20namespace\x20std;\n\nbool\x20cmp(pair<string,int>\x20a,pair<string,int>\x20b)\x20{\n\x20\x20return\x20a.first\x20<\x20b.first;\n}\n\nint\x20main()\x20{\n\x20\x20int\x20N,M;\n\x20\x20cin\x20>>\x20N;\n\x20\x20vector\x20followList(N);\n\x20\x20for\x20(int\x20i\x20=\x200;i\x20<\x20N;i++)\x20{\n\x20\x20\x20\x20cin\x20>>\x20followList[i];\n\x20\x20}\n\x20\x20cin\x20>>\x20M;\n\x20\x20map<string,int>\x20likeCount;\n\x20\x20for\x20(int\x20i\x20=\x200;i\x20<\x20M;i++)\x20{\n\x20\x20\x20\x20string\x20userID;\n\x20\x20\x20\x20int\x20count;\n\x20\x20\x20\x20cin\x20>>\x20userID\x20>>\x20count;\n\x20\x20\x20\x20likeCount[userID]\x20=\x20count;\n\x20\x20}\n\x20\x20int\x20totalLike\x20=\x200;\n\x20\x20for\x20(auto\x20it\x20=\x20likeCount.begin();it\x20!=\x20likeCount.end();it++)\x20{\n\x20\x20\x20\x20totalLike\x20+=\x20it->second;\n\x20\x20}\n\x20\x20int\x20avgLike\x20=\x20totalLike\x20/\x20M;\n\x20\x20vector<pair<string,int>>\x20possibleSecretFollow;\n\x20\x20for\x20(auto\x20it\x20=\x20likeCount.begin();it\x20!=\x20likeCount.end();it++)\x20{\n\x20\x20\x20\x20if\x20(it->second\x20>\x20avgLike\x20&&\x20find(followList.begin(),followList.end(),it->first)\x20==\x20followList.end())\x20{\n\x20\x20\x20\x20\x20\x20possibleSecretFollow.push_back(make_pair(it->first,it->second));\n\x20\x20\x20\x20}\n\x20\x20}\n\x20\x20sort(possibleSecretFollow.begin(),possibleSecretFollow.end(),cmp);\n\x20\x20if\x20(possibleSecretFollow.empty())\x20{\n\x20\x20\x20\x20cout\x20<<\x20"Bing\x20Mei\x20You"\x20<<\x20endl;\n\x20\x20}else\x20{\n\x20\x20\x20\x20for\x20(int\x20i\x20=\x200;i\x20<\x20possibleSecretFollow.size();i++)\x20{\n\x20\x20\x20\x20\x20\x20cout\x20<<\x20possibleSecretFollow[i].first\x20<<\x20endl;\n\x20\x20\x20\x20}\n\x20\x20}\n\x20\x20return\x200;\n} 原文地址: http://www.cveoy.top/t/topic/pEkY 著作权归作者所有。请勿转载和采集! 免费AI点我,无需注册和登录