小红书笔试

100 100 18

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

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

统一回复:

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

第二题:稳定排序直接秒

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

全部评论
编程题考纯数学题的都是***
8 回复 分享
发布于 2024-03-17 20:45 江苏
第二题我为啥只过9%
5 回复 分享
发布于 2024-03-17 20:56 湖北
第一次ak了,这次确实是很简单。第三题,我觉得是一个脑筋急转弯,只要赞为奇数的笔记不为0,那么无数次操作后,奇数赞的笔记数是趋近于偶数赞的笔记数,也就是说两者是会趋近相等的。无论什么情况(除了奇数赞为0的情况)和两者相等的情况其实是一样的。两者一样的话,就只需要考虑平均每个笔记点赞后能成为偶数的概率是多少,很显然是1/2,也就是说对于每个笔记,需要操作两次才能是偶数。所以最后的期望其实就是2*sum
3 回复 分享
发布于 2024-03-17 21:33 安徽
大佬第二题怎么做到100%的
2 回复 分享
发布于 2024-03-17 21:04 上海
世另我
1 回复 分享
发布于 2024-03-17 21:37 江苏
第二题题目中提到要是关键词数量一样,就按输入的先后顺序排
1 回复 分享
发布于 2024-03-17 21:08 安徽
第二题我也只有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 回复 分享
发布于 2024-03-17 21:03 四川
第一题为啥我只能73
1 回复 分享
发布于 2024-03-17 20:43 浙江
为什么没挂我也没给我发笔试通知
点赞 回复 分享
发布于 2024-03-21 00:56 江苏
第一题82,int和long long都82,其他超时,不知道为什么
点赞 回复 分享
发布于 2024-03-19 00:05 天津
我第一题也是用的那个函数,最后用了round,可能是round函数最后不是四舍五入吧,哎
点赞 回复 分享
发布于 2024-03-18 07:55 安徽
有没有好心人能告诉我第三题这种题在哪能练练,我推了半小时公式推出来了但是不会实现
点赞 回复 分享
发布于 2024-03-17 22:04 美国
第一题我用排列组合数做,A(n,2)记不清楚公式了,写成从n一直乘到2,应该是n乘到n–1。2/A(n,2),这还通过9%,服了,送分题都没做出来
点赞 回复 分享
发布于 2024-03-17 21:35 北京
第一题为啥我一直36%,python。。。
点赞 回复 分享
发布于 2024-03-17 21:20 上海
一样 三一点不会
点赞 回复 分享
发布于 2024-03-17 21:16 浙江
第二题可以重写排序器
点赞 回复 分享
发布于 2024-03-17 21:14 上海
一样,第三题级数公式是啥啊,我的∑(sum+2*i-1)/n^i,带入进去就9+9
点赞 回复 分享
发布于 2024-03-17 21:09 北京
最后一题想的电脑都黑屏了 同18
点赞 回复 分享
发布于 2024-03-17 21:09 美国
佬,看看我的第二题,卡死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>
点赞 回复 分享
发布于 2024-03-17 21:09 江苏
第一题82,第二题0,第三题写半天0最后直接输出6骗了9分
点赞 回复 分享
发布于 2024-03-17 21:07 湖北

相关推荐

自由水:笑死了,敢这么面试不敢让别人说
点赞 评论 收藏
分享
评论
6
4
分享

创作者周榜

更多
牛客网
牛客企业服务