当前位置:网站首页>ACM notes
ACM notes
2022-06-28 07:29:00 【Artificial mental retardation replaced by artificial intelligen】
#include<bits/stdc++.h>
stl
1.
sort( Array first address , Array tail address , Sort rule )
Default from small to large
Left closed right away
sort(arr, arr+n, greater<int>());
Or write it yourself bool function
bool cmp(int a,int b) { return a>b; } int n=5, arr[M]={1,5,4,2,3}; sort(arr, arr+n, cmp);
2.pair
pair<int,double> p;
pair<pair<int,double>,pair<int,double>> pp;
p.first p.second make_pair(v1,v2)
3. Stack
stack<int> s;
s.push(x);
s.pop();
s.top();
s.size();
The above operations are O(1)
4. queue
queue<int> q;
q.push(x);
q.pop();
q.front();
q.size();
5.vector
Variable length array , vector
Variable length array , It is suitable for those who don't know how much to open in advance , Or if you want to transfer parameters quickly and easily .
vector<int> vc;
vc.push_back(x);
vc.size();
vc[i];
6.string
character string , In a sense, it can be regarded as vector<char>.
string s1,s2;
s1=“XJTUICPC”
cin>>s2;
s1.size();
s1+=s2;
s1.find(s2);
7.map
mapping , Associative array
Pair with key value (pair) Orderly storage , You can operate in an array like manner .
map<int,int> mp;
mp[114514] = 5;
mp[1919810]++;
printf(“%d”,mp);
Unspecified values default to 0
8
An operation ( And &, or |, Exclusive or ^, Not ~, Move left << , Move right >>
1&1=1 1&0=0 0&1=0 0&0=0
1|1=1 1|0=1 0|1=1 0|0=0
Exclusive or 1⊕1=0 1⊕0=1 0⊕1=1 0⊕0=0 0⊕a=a a⊕a=0 a⊕b=b⊕a (a⊕b)⊕c=a⊕(b⊕c) It is known that a⊕b=c If we knew a and c, seek b?
~1=0 ~0=1
5≪2 = 20 5≫2=1
20=(10100)_2
5 =(00101)_2
1 =(00001)_2 If you move right past the rightmost end ? If you move left past the leftmost end ? The crossing part is gone ! It can be used to multiply and divide quickly 2 The power of .
Looking for chopsticks : Exclusive or
There are several pairs of chopsticks , Chopsticks need the same length to form a pair . One of the chopsticks was taken away , Here you are n The length of chopsticks , Ask the length of the one you took away .
9. Given a size of n Set , Determine how many subsets exist in the set , The sum of all elements in the subset is exactly 0 .
enumeration ( Binary system )
Half enumeration : We consider splitting the set into two halves , The sizes are ⌊n/2⌋ and ⌈n/2⌉, Write it down as A and B, Share one map
10. Dictionary order
for example a = “aabbc”, b = “aacbc” , Then the dictionary order a<b.
for example a = [1, 2, 1], b = [1, 1, 6, 7] , Then the dictionary order a>b.
for example a = [1, 1], b = [1, 1, 1] , Then the dictionary order a<b.
for example a = [1, 2, 3], b = [1, 2, 3] , Then the dictionary order a=b.
11. Modular arithmetic
% and mod Dissimilarity
(a±b)modp=(amodp±bmodp)modp
(a×b)modp=((amodp)×(bmodp))modp
a^bmodp=(amodp)^bmodp
边栏推荐
- Leetcode+ 66 - 70 high precision, two sub topics
- DBeaver 22.1.1 发布,可视化数据库管理平台
- QT -- communication protocol
- 8 张图 | 剖析 Eureka 的首次同步注册表
- Yesterday, I went to a large factory for an interview and asked me to do four arithmetic operations. Fortunately, I am smart enough
- R 语言 ggmap 可视化集群
- LeetCode+ 66 - 70 高精度、二分专题
- Server body 18: understanding and thinking of UDP reliable transmission (feeling from reading Yunfeng blog)
- [c #] [reprint]furion frame address and tutorial address
- 在idea中,get和set方法爆红可能是没有安装Lombok插件
猜你喜欢

2021 VDC: technological architecture evolution of vivo Internet service for 100 million users | PPT download attached

ABAP skill tree

Jinshan cloud team shared | 5000 words to understand how Presto matches with alluxio

Cloud native (to be updated)

vite2.9 中指定路径别名

分析 NFT 项目的 5 个指标

HTTP Caching Protocol practice

Design and implementation of spark offline development framework

In idea, the get and set methods may be popular because the Lombok plug-in is not installed

The practice of traffic and data isolation in vivo Reviews
随机推荐
扩展Prometheus的解决方案thanos的简介和几个月使用心得
What is a consistent hash? What scenarios can it be applied to?
分析 NFT 项目的 5 个指标
Understanding of OPC protocol
BACnet/IP網關如何采集樓宇集中控制系統數據
[ thanos源码分析系列 ]thanos query组件源码简析
Encyclopedia of scala operators
什么是一致性哈希?可以应用在哪些场景?
Practice and exploration of vivo live broadcast application technology
实时数据库 - 笔记
Solving the longest palindrome substring by dynamic programming
Is it safe to open an account on Dongfang fortune
vite2.9 中指定路径别名
SQL statement optimization steps (1)
QT -- communication protocol
LeetCode+ 51 - 55 回溯、动态规划专题
云原生(待更新)
8 张图 | 剖析 Eureka 的首次同步注册表
Makefile
Design and implementation of spark offline development framework
