当前位置:网站首页>ACM笔记
ACM笔记
2022-06-28 07:23:00 【被人工智能取代的人工智障】
#include<bits/stdc++.h>
stl
1.
sort(数组首地址,数组尾地址,排序规则)
默认从小到大
左闭右开
sort(arr, arr+n, greater<int>());
或者自己写个bool函数
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<int> s;
s.push(x);
s.pop();
s.top();
s.size();
上述操作均为O(1)
4.队列
queue<int> q;
q.push(x);
q.pop();
q.front();
q.size();
5.vector
变长数组,向量
变长数组,适用于预先不知道开多大,或者想要轻快简便传参的情况。
vector<int> vc;
vc.push_back(x);
vc.size();
vc[i];
6.string
字符串,某种意义下可以认为是vector<char>。
string s1,s2;
s1=“XJTUICPC”
cin>>s2;
s1.size();
s1+=s2;
s1.find(s2);
7.map
映射,关联数组
以键值对(pair)的方式有序存储,可以使用类似数组的方式去操作。
map<int,int> mp;
mp[114514] = 5;
mp[1919810]++;
printf(“%d”,mp);
未指定的值默认0
8
位运算(与&,或|,异或^,非~,左移 << ,右移 >>
1&1=1 1&0=0 0&1=0 0&0=0
1|1=1 1|0=1 0|1=1 0|0=0
异或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) 已知 a⊕b=c 如果我们知道a和c,求b?
~1=0 ~0=1
5≪2 = 20 5≫2=1
20=(10100)_2
5 =(00101)_2
1 =(00001)_2 如果右移越过最右端?如果左移越过最左端? 过界部分就没了! 可以用来快速乘除2的幂次。
找筷子:异或
有若干双筷子,筷子需要长度一样的才能组成一双。其中一只筷子被拿走了,给你剩下n只筷子的长度,问拿走的那只的长度。
9.给定一个大小为 n 的集合,判断该集合中存在多少个子集,满足子集中所有元素之和恰好为 0 。
枚举(二进制)
折半枚举:我们考虑将集合分成两半,大小分别为 ⌊n/2⌋ 和⌈n/2⌉,记为 A 和 B,共用一个map
10.字典序
例如 a = “aabbc”, b = “aacbc” ,则字典序 a<b。
例如 a = [1, 2, 1], b = [1, 1, 6, 7] ,则字典序 a>b。
例如 a = [1, 1], b = [1, 1, 1] ,则字典序 a<b。
例如 a = [1, 2, 3], b = [1, 2, 3] ,则字典序 a=b。
11.模运算
%和mod不一样
(a±b)modp=(amodp±bmodp)modp
(a×b)modp=((amodp)×(bmodp))modp
a^bmodp=(amodp)^bmodp
边栏推荐
- Mysql57 zip file installation
- Is it safe to open an account on Dongfang fortune
- My MVVM open source project "travel epidemic prevention app" has been released
- Vivo browser rapid development platform practice - Overview
- kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑
- 阿里云服务器创建快照、回滚磁盘
- Libuv framework echo server C source code explanation (TCP part)
- XML序列化向后兼容
- PLC -- 笔记
- R language hitters data analysis
猜你喜欢

No suspense about the No. 1 Internet company overtime table

网传互联网公司加班表,排名第一的没悬念
![[thanos source code analysis series]thanos query component source code analysis](/img/e4/2a87ef0d5cee0cc1c1e1b91b6fd4af.png)
[thanos source code analysis series]thanos query component source code analysis

在idea中,get和set方法爆红可能是没有安装Lombok插件

MySQL installation steps - installing MySQL on Linux (3)

es6箭头函数中return的用法

Comment la passerelle BACnet / IP recueille - t - elle les données du système central de contrôle des bâtiments?

Comprehensive analysis of real enterprise software testing process

数字藏品市场“三大套路”

Modifying MySQL user name root under Linux
随机推荐
The practice of event driven architecture in vivo content platform
Wechat applets - basics takes you to understand the life cycle of applets (I)
MySQL installation steps - installing MySQL on Linux (3)
SQL statement optimization steps (1)
R 语言 Kolmogorov-Smirnov 检验 2 个样本是否遵循相同的分布。
Is it safe for flush to open an account online
Application and Optimization Practice of redis in vivo push platform
2021 VDC: technological architecture evolution of vivo Internet service for 100 million users | PPT download attached
Mysql8.0和Mysql5.0访问jdbc连接
阿里云服务器创建快照、回滚磁盘
What should I do if the version is incompatible with the jar package conflict?
Drawing animated bubble chart with R language
Top 25 most popular articles on vivo Internet technology in 2021
LLVM 与 Clang
R 语言 ggmap
Comment la passerelle BACnet / IP recueille - t - elle les données du système central de contrôle des bâtiments?
大型项目中的Commit Message规范化控制实现
Yesterday, I went to a large factory for an interview and asked me to do four arithmetic operations. Fortunately, I am smart enough
Devtools implementation principle and performance analysis practice
Encyclopedia of scala operators
