05 2021 档案
-
数据结构--树状数组
摘要:证明参考:https://zhuanlan.zhihu.com/p/297885717(抄的) 树状数组支持的操作:单点修改,区间查询(仅限于支持减法的操作,不支持的例子:max) 树状数组定义:定义C[ i ] 表示的是A [ i - lowbit(i) ] + 1 ~~ A[ i ] 之间的数据 阅读全文
-
leetcode周赛 242
摘要:A:水题,给定01串,问连续的0更长还是连续的1更长。 直接遍历即可。 1 class Solution { 2 public: 3 bool checkZeroOnes(string s) { 4 int res1=0,res0=0; 5 int cnt1=0,cnt0=0; 6 for(int 阅读全文
-
AcWing第二次热身赛
摘要:A:水题,找到不小于n的能够被4整除的最小的数。 假设n不能被4整除,那么n+1,n+2,n+3之中一定存在一个数能够被4整除。所以直接枚举即可。 1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 using na 阅读全文
-
AcWing夏季每日一题--最长公共子序列
摘要:https://www.acwing.com/problem/content/3513/ 其中一个串不重复是公共子序列问题转换为上升子序列问题的一个充要条件。 #include <iostream> #include <cstring> #include <algorithm> using name 阅读全文
-
AcWIng夏季每日一题--序列最大收益
摘要:https://www.acwing.com/problem/content/3502/ 1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 int n,k,m; 6 c 阅读全文
-
leetcode周赛 241
摘要:A:水题,直接暴搜就好了。 1 class Solution { 2 public: 3 int res; 4 void dfs(vector<int>&nums,int i,int sum){ 5 if(i==nums.size()){ 6 res+=sum; 7 return ; 8 } 9 d 阅读全文
-
第十二届蓝桥杯C++ B组
摘要:A:计算256MB能够存放多少个int 1 int main() 2 { 3 cout<<256*1024*1024/4; 4 return 0; 5 } ans=67108864 B:计算2021张1到10的卡片能够拼出1~n的最大的n 1 int cnt[10]; 2 int main() 3 阅读全文
-
leetcode周赛 239
摘要:A:水题,直接枚举即可。 1 class Solution { 2 public: 3 int getMinDistance(vector<int>& nums, int target, int start) { 4 int res=0,seq=INT_MAX; 5 for(int i=0;i<nu 阅读全文