bing糖雪狸
bing糖雪狸
全部文章
分类
归档
标签
去牛客网
登录
/
注册
bing糖雪狸的博客
全部文章
(共29篇)
题解 | 二进制不同位数
题目信息平台:牛客题目:二进制不同位数难度:简单题目链接题目描述给定两个整数 m、n,计算它们二进制表示中不同位的数量。初步思路不同位的数量等价于 m 与 n 的异或结果中 1 的个数。用 x = m ^ n 得到所有不同位。通过 x &= x - 1 每次消去最低位的 1,并计数。 示例 ...
2026-01-22
1
64
题解 | 【模板】静态区间和(前缀和)
题目描述给定长度为 n 的数组和 q 次查询,每次给出区间 [l, r],输出该区间元素之和。数组不修改。初步思路1. 朴素做法如果每次查询都直接遍历区间 [l, r] 求和,时间复杂度为 O(n)。对于 q 次查询,总时间复杂度为 O(nq)。2. 前缀和优化我们需要快速求出区间和,利用前缀和可以...
2026-01-21
0
52
题解 | 阅读理解
题目信息平台:牛客题目:阅读理解难度:简单题目链接题目描述给定 n 篇文章,每篇文章包含若干单词。随后有 m 次查询,每次给出一个单词,需要输出所有包含该单词的文章编号(按从小到大),若不存在则输出空行。初步思路预处理阶段用哈希表建立“单词 -> 出现的文章编号列表”。每篇文章内重复单词只记录...
2026-01-19
0
57
题解 | 有趣的区间
题目信息平台:牛客题目:有趣的区间题目链接题目描述给定长度为 n 的整数数组,统计满足条件的子区间数量。根据代码语义推断:区间内至少包含一个奇数时,该区间被视为“有趣”。初步思路总子区间数为 n*(n+1)/2。只要扣掉“全为偶数”的子区间数,剩下的就是至少包含一个奇数的区间数。统计连续偶数段长度 ...
2026-01-18
0
69
题解 | 【模板】静态区间最值
#include<bits/stdc++.h> #define il inline #define endl '\n' using namespace std; #define pb push_back #define fastio \ ios::sync_with_stdio(f...
2025-12-14
0
60
题解 | 点到直线距离
#include <bits/stdc++.h> using namespace std; struct point { double x, y; point(double A, double B) { x = A, y = B; } p...
2025-12-13
0
60
题解 | 最厉害的学生
#include <algorithm> #include <functional> #include <iomanip> #include <iostream> #include <queue> #include <string&g...
2025-12-13
0
59
题解 | 质数统计
#include<iostream> #include<vector> #define il inline using namespace std; #define fastio \ ios::sync_with_stdio(false); \ cin.tie(0)...
2025-12-04
0
52
题解 | 小A弹吉他
#include<bits/stdc++.h> #define il inline using namespace std; #define pb push_back #define fastio \ ios::sync_with_stdio(false); \ cin.tie...
2025-11-22
0
41
题解 | 小苯的计算式
#include <bits/stdc++.h> #define il inline using namespace std; #define pb push_back #define fastio \ ios::sync_with_stdi...
2025-11-21
0
33
首页
上一页
1
2
3
下一页
末页