ICode9

精准搜索请尝试: 精确搜索
  • c++ 内建函数对象2022-05-01 18:02:58

    内建函数对象意义 概念: STL内建了一些函数对象 分类: 算术仿函数 关系仿函数 逻辑仿函数 用法: 这些仿函数所产生的对象,用法和一般函数完全相同 使用内建函数对象,需要引入头文件 #include<functional>  算术仿函数 功能描述: 实现四则运算 其中negate是一元运算,其他

  • C++ 类模板和函数模板2022-04-30 19:03:57

    函数模板 当我们想要定义一个可以支持泛型的函数时,就要采用函数模板的方式了。所谓泛型就是可以支持多种类型的操作,比如我们定义一个compare操作,他可以根据传递给他的参数类型动态调用对应的函数版本,实现多种类型的比较。 template <typename T> int compare(const T &v1, const T

  • c++deque容器2022-04-30 18:34:15

    deque容器   deque容器基本概念 功能: 双端数组,可以对头端进行插入删除操作 deque与vector区别: vector对于头部的插入删除效率低,数据量越大,效率越低 deque相对而言,对头部的插入删除速度回比vector快 vector访问元素时的速度会比deque快,这和两者内部实现有关       deque内

  • 力扣78题2022-04-29 17:02:28

    方法一: binary 不使用递归 class Solution { public: vector<vector<int>> subsets(vector<int>& nums) { vector<vector<int>> ans; int n = nums.size(); for (int i = 0; i < 1 << n; i ++ ) {

  • Leetcode 398 随机数索引2022-04-26 00:00:35

    Given an integer array nums with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array. Implement the Solution class: Solution(int[] nums) Initializes the object with

  • [AcWing 793] 高精度乘法2022-04-25 21:36:16

    点击查看代码 #include<iostream> #include<vector> using namespace std; vector<int> mul(vector<int>& A, int b) { vector<int> C; int t = 0; for (int i = 0; i < A.size() || t; i++) { if (i < A.size())

  • 单调队列2022-04-25 13:01:15

    luogu: https://www.luogu.com.cn/problem/P1886 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, k, a[N]; void getMin(){ vector <int> ans; deque <int> q; for (int i = 1; i <= n; i ++ ){ while (q.size() &

  • c++vector 遍历2022-04-24 17:01:50

       vector存放内置数据类型 容器: vector 算法: for_each 迭代器: vector<int>::iterator 示例:   #include <vector> #include <algorithm> void MyPrint(int val) { cout << val << endl; } void test01() { //创建vector容器对象,并且通过模板参数指定容器中存放

  • 力扣第290场周赛T3T42022-04-24 13:01:15

    t3.统计包含每个点的矩阵数目 题意 给定一些矩阵和一些点,计算每个点被多少个矩阵包含着 思路 题目中矩阵的高度范围是1~100,因此,将每个高度对应的矩阵宽度存下来,排序。枚举每个点,每个点枚举高度比它大的,然后在每个高度中二分宽度,找到第一个大于点的宽度。 找到每个高度有多少个矩阵

  • 学习笔记--Vector容器(C++)2022-04-23 18:01:08

    ​   STL基本概念 STL(Standard Template Library,标准模板库) STL 从广义上分为: 容器(container) 算法(algorithm) 迭代器(iterator) 容器和算法之间通过迭代器进行无缝连接。 STL 几乎所有的代码都采用了模板类或者模板函数 STL六大组件 STL大体分为六大组件,分别是

  • java8 LocalDateTime 格式化2022-04-22 15:00:38

    LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) TRANSLATE with x English Arabic Hebrew Polish Bulgarian Hindi Portuguese Catalan Hmong Daw Romanian Chinese Simplified Hungarian Russian Chinese T

  • 算法练习——有效括号2022-04-21 22:01:00

    使用栈,先将左括号入栈,然后遍历字符串,在对括号进行匹配 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。 //有效的括号 #include<iostream> #include<stack> #include<string> #include<vector> using namespa

  • XIX Open Cup Onsite: E - Power of Function (数位+思维)2022-04-20 22:02:09

    观察到:我们可以从高位到第低位枚举第一个l和r不同的位置,记为diff,那么使得m取得最大的n有两种情况:要么n=r,要么n!=r,如果n!=r,那么要使得m最大,只有在 \[diff<=x<最大的位数 \]时,在[0,x-1]位上,n与r相同,x位上n=mr[x]-1,[x+1,最大位数]上全部填上k-1,故可以枚举x,加一个前缀和优化,复杂度是

  • 动态规划||单调队列 LeetCode1438.绝对差不超过限制的最长连续子数组2022-04-17 11:03:50

    1438.绝对差不超过限制的最长连续子数组        题目大意就是求最大连续的区间,使最大值减最小值小于等于limit. 数据范围:     一、Binary Tree 考虑枚举每一个区间,记录每一段长度并且更新ans,每一段长度里面都得满足max-miin<=limit,不满足就把删掉区间的左端点值,直到满

  • L2-040 哲哲打游戏2022-04-16 18:02:36

    这题读懂题目之后就发现它很呆 #include <bits/stdc++.h> using namespace std; const int N = 100010, M = 110; vector<int> g[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i &

  • 简单的自制类(包含迭代器的使用)2022-04-16 13:32:33

    #include<bits/stdc++.h> using namespace std; struct Array_iterator{ int *ptr; void operator++(){ ptr++; } int operator*(){ return *ptr; } bool operator!=(Array_iterator x){ if(ptr==x.ptr)return false; else return true; } }; struct Arr

  • [AcWing 774] 最长单词2022-04-14 12:33:31

    点击查看代码 #include<iostream> using namespace std; string str, res; int main() { while (cin >> str) { if (str.back() == '.') str.pop_back(); if (str.size() > res.size()) res = str; } cout << res

  • 英语特殊疑问句2022-04-14 01:03:27

    概念 特殊疑问句是在英语中以特殊疑问词开头,对句中某一成分提问的句子。根据疑问词分类有疑问代词、疑问副词、疑问形容词: 疑问词 包含 疑问代词 what、who、which 疑问副词 when、where、why、how 疑问形容词 whose 变形 知道特殊疑问句的主语,询问 "他/他们/我可以

  • 验证码之滑块验证码2022-04-13 10:03:50

    class SlideCrack(object): def __init__(self, gap, bg): """ init code :param gap: 缺口图片 :param bg: 背景图片 :param out: 输出图片 """ self.front = gap self.bg = bg

  • LeetCode 239. 滑动窗口最大值2022-04-11 19:00:06

    题目: 给定数组和窗口大小k,输出滑动过程中窗口的最大值 解法: 本题求得是窗口内的最大值,而滑动这一性质又要求不能随意丢弃信息。这里可以使用单调队列来完成这个需求——保留一定的信息、动态变化,现在问题是如何设计这个单调队列。我们维护一个单调减的队列,由此,每次队列pop_front之

  • 项目自动备份,oracle 自动备份2022-04-11 14:01:43

    1 项目备份      变量的形式 定时任务不执行就都写成了绝对路径 #!/bin/bash # # 项目路径 /usr/local/tomcat-bjkjdx 备份文件路径/usr/local/bak #BACKUP_BASE=/usr/local #/user/local/bak #BACKUP_HOME=$BACKUP_BASE/bak #判断是都存在bak文件自动创建 if [ !

  • 对象扁平化2022-04-11 08:33:07

    递归 function flat(obj) { // 你的代码 const back = {}; recursion(obj, null); function recursion(o, prev) { for (let key in o) { if (o[key] instanceof Object) { if (prev === null) { recurs

  • CF problem: (D) Maximum Product Strikes Back2022-04-03 21:00:31

    Problem - D - Codeforces       Example input 5 4 1 2 -1 2 3 1 1 -2 5 2 0 -2 2 -1 3 -2 -1 -1 3 -1 -2 -2   output 0 2 3 0 2 0 0 1 1 0     最近赛中敲不出代码, 赛后倒是镇静了, 我也醉了 简述下思路及变量意义:  这里采取从前到尾遍历,由于数据范围不能完

  • 131. 分割回文串2022-04-02 17:31:35

    ✅做题思路or感想 这题的主题有两个:分割字符串,检查是否回文 难点在于第一点,这里用startIndex作为子串开始的地方,i作为子串结束的地方,用s.substr(startIndex, i - startIndex + 1)来分割出子串 递归单层逻辑就是判断子串是否回文,如果回文,则加入vector<string>中,否则continue class

  • 【算法基础】蓝桥杯入门算法2022-03-31 03:00:08

    一、STL库 1.动态数组 vector<int> a .push_back() .pop.back() .size() .clear()        可能存在空间爆炸问题,用  vector<int> () .swap(v)来解决。 2.集合 set<int> v .insert() .erase() .cout() 比较方式: Bool operator<(const people &rhs) const { Return h

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有