小红书笔试

100 100 18

第三题求期望真不是人做的

----------------------------------------------------

统一回复:

第一题:1/(n(n-1)/2),注意用 double,直接秒

第二题:稳定排序直接秒

第三题:print(sum(arr) + oddCnt * 3),骗 18%

全部评论
编程题考纯数学题的都是***
7 回复
分享
发布于 03-17 20:45 江苏
第二题我为啥只过9%
5 回复
分享
发布于 03-17 20:56 湖北
滴滴
校招火热招聘中
官网直投
第一次ak了,这次确实是很简单。第三题,我觉得是一个脑筋急转弯,只要赞为奇数的笔记不为0,那么无数次操作后,奇数赞的笔记数是趋近于偶数赞的笔记数,也就是说两者是会趋近相等的。无论什么情况(除了奇数赞为0的情况)和两者相等的情况其实是一样的。两者一样的话,就只需要考虑平均每个笔记点赞后能成为偶数的概率是多少,很显然是1/2,也就是说对于每个笔记,需要操作两次才能是偶数。所以最后的期望其实就是2*sum
3 回复
分享
发布于 03-17 21:33 安徽
大佬第二题怎么做到100%的
2 回复
分享
发布于 03-17 21:04 上海
第一题为啥我只能73
1 回复
分享
发布于 03-17 20:43 浙江
第二题我也只有9% 不知道为啥 #include<iostream> #include<string> #include<vector> #include<unordered_map> #include<map> #include<unordered_set> using namespace std; struct cmp { bool operator()(int a, int b) { return a > b; } }; int main() { int n, q; cin >> n >> q; vector<string> userSearch(q); for (int i = 0; i < q; i++) cin >> userSearch[i]; unordered_map<string>>hash; vector<string> productList; for (int i = 0; i < n; i++) { string product; cin >> product; productList.push_back(product); int keyCount; cin >> keyCount; unordered_set<string> set; for (int j = 0; j < keyCount; j++) { string keyWord; cin >> keyWord; set.emplace(keyWord); } hash[product] = set; } map<int>rank; for (auto & product : productList) { int cover = 0; unordered_set<string> & currSet = hash[product]; for (auto & currKey : userSearch) { if (currSet.count(currKey)) cover++; } rank[cover] = product; } for (auto & kv : rank) { cout << kv.second << endl; } }</string></int></string></string></string></string></unordered_set></map></unordered_map></vector></string></iostream>
1 回复
分享
发布于 03-17 21:03 四川
第二题题目中提到要是关键词数量一样,就按输入的先后顺序排
1 回复
分享
发布于 03-17 21:08 安徽
世另我
1 回复
分享
发布于 03-17 21:37 江苏
期望那个吗 确实抽象
点赞 回复
分享
发布于 03-17 20:39 上海
这思路是什么呀。
点赞 回复
分享
发布于 03-17 20:41 广东
直接没做交了,头给我看晕了。。
点赞 回复
分享
发布于 03-17 20:47 江苏
期望吐了🤮
点赞 回复
分享
发布于 03-17 20:47 云南
期望直接打印了一个6,然后交卷了
点赞 回复
分享
发布于 03-17 20:50 重庆
第二题我最高55%
点赞 回复
分享
发布于 03-17 21:05 湖北
第一题82,第二题0,第三题写半天0最后直接输出6骗了9分
点赞 回复
分享
发布于 03-17 21:07 湖北
佬,看看我的第二题,卡死9%了 #include<iostream> #include<string> #include<vector> #include<algorithm> #include<map> using namespace std; typedef pair<string> PAIR; struct cmp{ bool operator()(const PAIR& l, const PAIR& r){ return l.second > r.second; } }; int main(){ int n,q; cin>>n>>q; map<string> m; vector<pair> vec; for(int i=0;i<q>>tmp; m.insert(PAIR(tmp,i)); } for(int i=0;i<n>>s1; int tmp; cin>>tmp; int count=0; for(int k=0;k<tmp>>s2; map<string>::iterator it = m.find(s2); if(it!=m.end()) count++; } vec.push_back(PAIR(s1, count)); } sort(vec.begin(), vec.end(),cmp()); for(int i=0;i!=vec.size();i++){ cout<</string></tmp></n></q></pair></string></string></map></algorithm></vector></string></iostream>
点赞 回复
分享
发布于 03-17 21:09 江苏
最后一题想的电脑都黑屏了 同18
点赞 回复
分享
发布于 03-17 21:09 美国
一样,第三题级数公式是啥啊,我的∑(sum+2*i-1)/n^i,带入进去就9+9
点赞 回复
分享
发布于 03-17 21:09 北京
第二题可以重写排序器
点赞 回复
分享
发布于 03-17 21:14 上海
一样 三一点不会
点赞 回复
分享
发布于 03-17 21:16 浙江

相关推荐

6 4 评论
分享
牛客网
牛客企业服务