ICode9

精准搜索请尝试: 精确搜索
  • 剑指 Offer II 007. 数组中和为 0 的三个数2022-03-30 00:32:40

    暴力去重 class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { map<int, int> cnt; int n = nums.size(); for(int i = 0; i < n; i++) { if(cnt[nums[i]] == 0)

  • 113. 路径总和 II2022-03-28 23:00:50

    ✅做题思路or感想: 也是遍历一遍二叉树,判断路径总和和是否是叶子节点,要注意的是这里还需要加一个vector来记录路径 class Solution { public: vector<vector<int>>result; void dfs(TreeNode* cur, vector<int>vec, int sum) { //判断条件 if (sum ==

  • CSP 202112-3 登机牌条码 100分题解2022-03-27 09:33:25

    分析: 一步步按照它的要求来就是了。 多项式除法的过程要手动模拟(有点像高精度)。 一开始我50分,是只对答案取了模没对过程取模。 然后80分,发现3^k其实会爆long long。 注意每一处的细节(要不要取模) 代码 #include <bits/stdc++.h> using namespace std; #define File(x) freopen("(

  • 图的存储、遍历(BFS、DFS)2022-03-25 20:00:23

    一、图的存储      1、邻接矩阵(二维数组)             int mp[N][N];            2、边缘列表(结构体)            tip:用的很少,适用于需要对边权排序的题目 struct Edge { int u,v; }g[N];        3、邻接表            1)vector数组(c++自

  • 蓝桥--阶乘2022-03-21 21:05:02

        #include<iostream>#include<vector>//C++ 容器 详见下方链接using namespace std;vector<int> v;//声明了一个int数组v[],大小没有指定,可以动态的向里面添加删除int main(){   int n,i,j,t;   cin>>n;//输入n   v.push_back(1); //在数组的最后添加一个数据,初始化

  • 美团笔试(22.03.19)2022-03-19 23:35:43

    代码题 一共五道代码题,看了前面三道,ac了三道,后面两道题没有时间看,此处将对前三题进行记录总结,后附代码。 第一题 点餐 题意: 给定一组n个商品的价格,下单购买商品时,必须购买前i个商品,即购买商品列表是商品列表的前缀。提供两种优惠规则,满减优惠和折扣优惠,每次下单只能选择某种优惠规

  • P1601 A+B Problem(高精)2022-03-09 09:00:54

    题目链接 https://www.luogu.com.cn/problem/P1601 题目思路 模板 题目代码 #include <iostream> #include <algorithm> #include <vector> using namespace std; vector<int> a, b; vector<int> add(vector<int> &a, vector<int> &b

  • P1303 A*B Problem2022-03-09 09:00:07

    题目链接 https://www.luogu.com.cn/problem/P1303 题目思路 模板题 题目代码 #include <iostream> #include <algorithm> #include <vector> using namespace std; vector<int> a, b; vector<int> mult(vector<int> &a, vector<int> &

  • AcWing 1118. 分成互质组2022-03-07 17:03:23

    题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 20; const int INF = 0x3f3f3f3f; int n, a[N], ans = INF; int len; //现有组的数量 vector<int> g[N]; //最大公约数,辗转相除法 inline int gcd(int a, int b) { if (b == 0) return a; retu

  • vector容器2022-03-06 03:01:12

    一、简介: vector容器是一个单端容器,形式如下,   这是一个在std名字空间中定义的模板类: namespace std{ template <class T, class Allocator = allocator<T> > class vector;} 如果使用vector必须包含头文件<vector>。 二、vector类的操作: 1、创建、复制和销毁 1 void

  • poj 10682022-03-05 21:34:11

    1、注意理解题意 2、注意输出格式 代码: #include <cstdio>#include<iostream>#include<vector>using namespace std; int main() { int t; cin >> t; while (t--) { int num; cin >> num; vector<int> vec; while (num--) { int c; cin >> c

  • 算法之数学验证尼科彻斯定理2022-03-04 22:35:51

       分析和思路: 接受输入数据后,从1开始遍历,找到连续相加和的连续奇数即可。back变量的设置有些技巧。 1 #include <iostream> 2 #include "iostream" 3 #include "string" 4 5 using namespace std; 6 7 int main() 8 { 9 10 int number = 0; 11 while (ci

  • vector 建立二维数组2022-03-04 20:31:54

    方法一: #include <iostream> #include <vector> using namespace std; void test01() { //创建一个外层容器 vector<vector<int>>v; //创建一些内层容器,并赋值 vector<int>v1(10,1); vector<int>v2(10,2); vector<int>v3(10,3); //将内层小容器插入到大容器之中,类似于

  • 基于Butterfly的细分2022-03-03 23:33:10

    简介 即三角网格插值细分 参考文献 http://graphics.stanford.edu/courses/cs468-10-fall/LectureSlides/10_Subdivision.pdf TIPS w 采用1/16. 参考示意图 image code bug 调了很久,就是 一条半边对应面的方向其实不太稳定。 codeMain #pragma once #pragma once #include "str

  • SDUTACM20级集训队2022春季选拔赛--3(补题)2022-03-02 11:33:15

    E - Efficient Exchange 题意: 现在需要向银行支付\(X\)元钱,但是你和银行,但现在只有\(10\)的幂次方面值的硬币,问你给银行和银行找你的硬币数总和最少是多少? 思路: 定义\(f(i,0/1)\)为当前为是否多交1位,支付到当前位置的硬币的给和找回来的最小总和 比赛期间一直没想到合适的贪心策略

  • 杨辉三角浅解2022-03-01 21:35:38

      1。 class Solution { public:     vector<vector<int>> generate(int numRows) {         vector<vector<int>> tangle;         vector<int> a;         a.push_back(1);         tangle.push_back(a);         if(nu

  • acwing算法基础课文字版(看不懂你打我)——第二课基础算法之:高精度算法(大数乘小数、大数除小数)2022-03-01 18:02:02

    写在前面:acwing是由北大学长创立的算法学习平台,在IT资源良莠不齐的当下异军突起。只需一顿火锅钱,就能跟着获得noi金牌的北大学长学习算法,是IT初学者进行深入研究的不二平台。本系列帖子将围绕AcWing平台的主打课程——算法基础课,并辅以本人自己的学习心得与广大算法爱好者分

  • Mtk平台Update部分Metadata值2022-03-01 15:02:50

    (1)源码 //vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/common/v1/HalSensorList.buildStaticInfo.cpp MBOOL HalSensorList:: buildStaticInfo(Info const& rInfo, IMetadata& rMetadata) const { SensorStaticInfo *pSensorStaticInfo = &a

  • 四、STL函数对象(了解)2022-03-01 13:34:52

    4 STL- 函数对象 4.1 函数对象 4.1.1 函数对象概念 概念: 重载函数调用操作符的类,其对象常称为函数对象函数对象使用重载的()时,行为类似函数调用,也叫仿函数 本质: 函数对象(仿函数)是一个类,不是一个函数 4.1.2 函数对象使用 特点: 函数对象在使用时,可以像普通函数那样调用, 可以

  • 五、STL常用算法2022-03-01 13:32:15

    5 STL- 常用算法 概述: 算法主要是由头文件<algorithm> <functional> <numeric>组成。 <algorithm>是所有STL头文件中最大的一个,范围涉及到比较、 交换、查找、遍历操作、复制、修改等等 <numeric>体积很小,只包括几个在序列上面进行简单数学运算的模板函数 <functional>

  • CCF 2015-032022-02-28 10:02:58

    CCF 历年题目集 A. 图像旋转 按照题目写就行 #include <bits/stdc++.h> using namespace std; const int N = 1005; int a[N][N]; int main() { int n,m; cin >> n >> m; for (int i = 0 ; i < n ; i ++ ) for (int j = 0 ; j < m ; j ++ ) cin >> a[i]

  • c++priemr第十五章笔记 15.8容器与继承2022-02-27 18:59:47

    容器与继承 #include <iostream> #include<vector> #include<string> using namespace std; class Quote { public: Quote() = default; Quote(const string &book,double sale_price):booNo(book),price(sale_price){} const string& isbn

  • 最大的矩形 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi。这n个矩形构成了一个直方图。例如,下图中六个矩形的高度就分别是3, 1, 6, 5, 2,2022-02-27 15:01:50

    最大的矩形 文章目录 问题描述输入格式输出格式样例输入样例输出代码思路 问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi。这n个矩形构成了一个直方图。例如,下图中六个矩形的高度就分别是3, 1, 6, 5, 2, 3。 请找出能放在给定

  • LeetCode基础之递归 / 回溯——40. 组合总和 II2022-02-25 23:33:31

    给定一个候选人编号的集合 candidates 和一个目标数 target , 找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数字在每个组合中只能使用 一次 。 注意:解集不能包含重复的组合。 示例 1: 输入: candidates = [10,1,2,7,6,1,5], target = 8,

  • 力扣第一题 1. 两数之和2022-02-25 23:31:57

    力扣第一题 1. 两数之和 https://leetcode-cn.com/problems/two-sum/ 根据排序算法中的选择排序来做的。 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> v; for(int i = 0; i < nums.size(); i++)

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

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

ICode9版权所有