做网站编辑是不是也要做推广,妇科医生咨询在线咨询免费,网页制作视频的网站建设,工信部备案网站查询考前注意事项
1、DevCpp添加c11支持
点击 工具 - 编译选项 中添加#xff1a;
-stdc112、万能头文件
#include bits/stdc.h万能头文件的缺陷#xff1a;y1 变量 在cmath中用过了y1变量。 #include bits/stdc.h
using namespace std;// 错误示例
…考前注意事项
1、DevCpp添加c11支持
点击 工具 - 编译选项 中添加
-stdc112、万能头文件
#include bits/stdc.h万能头文件的缺陷y1 变量 在cmath中用过了y1变量。 #include bits/stdc.h
using namespace std;// 错误示例
int y1;int main() {scanf(%d, y1);printf(%d, y1);return 0;
}3、cin / cout 加速
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);注意加速命令后cin cout 不要同时和 scanf 和 printf 一起使用
4、数组范围
一维int数组最大开到 1e7C 1s 的时间复杂度控制到 1e8 ~ 1e9 枚举两个for嵌套每个for最多可以运行 10000 次枚举三个for嵌套每个for最多可以运行 464 次 int 型变量最大记为 2e9 , long long 最大记为 1e18 OI 赛制不开long long见祖宗
5、暴力蹭分
OI 赛制可以先想暴力再去想算法去优化时间/空间
for循环直接枚举、数组或者答案线性考虑二分枚举排列组合的方案要找规律可以直接写程序去找打表可以在本地一直跑跑出答案直接写到数组里交程序时候直接读出数组中计算好的答案即可。
6、根据数据范围反推算法时间复杂度 由数据范围反推算法复杂度以及算法内容 - AcWing 蓝桥杯板子
1、STL库 C STL总结 (wyqz.top) 2、试除法判定质数
bool is_prime(int x) {if (x 2) return false;for (int i 2; i x / i; i)if (x % i 0)return false;return true;
}3、线性质数筛
int primes[N], cnt; // primes[]存储所有素数
bool st[N]; // st[x]存储x是否被筛掉void get_primes(int n) {for (int i 2; i n; i) {if (!st[i]) primes[cnt] i;for (int j 0; primes[j] n / i; j) {st[primes[j] * i] true;if (i % primes[j] 0) break;}}
}4、快速幂
求 m^k mod p时间复杂度 O(logk)。
int qmi(int m, int k, int p) {int res 1 % p, t m;while (k) {if (k 1) res res * t % p;t t * t % p;k 1;}return res;
}5、Sort() 排序方法
从大到小排序
int arr[5] {5, 3, 1, 2, 4};
sort(arr, arr 5, greater()); // 5 4 3 2 1vector排序
vectorint vec {5, 3, 1, 2, 4};
sort(vec.begin(), vec.end(), greater()); // 5 4 3 2 1cmp() 自定义排序函数
bool cmp(int x, int y) {return x y;
}int main() {int arr[5] {5, 3, 1, 2, 4};sort(arr, arr 5, cmp); // 5 4 3 2 1
}6、进制转换
string digits 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ;// 将十进制数转换为指定进制的字符串
string convertToBase(int num, int base) {string result ;while (num 0) {result digits[num % base] result;num / base;}return result;
}// 将指定进制的字符串转换为十进制数
int convertFromBase(string numStr, int base) {int result 0;for (int i 0; i numStr.length(); i) {int d digits.find(numStr[i]);result d * pow(base, numStr.length() - 1 - i);}return result;
}
文章转载自: http://www.morning.ydnxm.cn.gov.cn.ydnxm.cn http://www.morning.jppdk.cn.gov.cn.jppdk.cn http://www.morning.fqsxf.cn.gov.cn.fqsxf.cn http://www.morning.frllr.cn.gov.cn.frllr.cn http://www.morning.nnhrp.cn.gov.cn.nnhrp.cn http://www.morning.xpqyf.cn.gov.cn.xpqyf.cn http://www.morning.slysg.cn.gov.cn.slysg.cn http://www.morning.ckhyj.cn.gov.cn.ckhyj.cn http://www.morning.qswws.cn.gov.cn.qswws.cn http://www.morning.xrtsx.cn.gov.cn.xrtsx.cn http://www.morning.ywrt.cn.gov.cn.ywrt.cn http://www.morning.nsrlb.cn.gov.cn.nsrlb.cn http://www.morning.pqqzd.cn.gov.cn.pqqzd.cn http://www.morning.prxqd.cn.gov.cn.prxqd.cn http://www.morning.lhqw.cn.gov.cn.lhqw.cn http://www.morning.mtsgx.cn.gov.cn.mtsgx.cn http://www.morning.ydxx123.cn.gov.cn.ydxx123.cn http://www.morning.hchrb.cn.gov.cn.hchrb.cn http://www.morning.wmmqf.cn.gov.cn.wmmqf.cn http://www.morning.qsmch.cn.gov.cn.qsmch.cn http://www.morning.rbbzn.cn.gov.cn.rbbzn.cn http://www.morning.amlutsp.cn.gov.cn.amlutsp.cn http://www.morning.bqpg.cn.gov.cn.bqpg.cn http://www.morning.jhrkm.cn.gov.cn.jhrkm.cn http://www.morning.qtltg.cn.gov.cn.qtltg.cn http://www.morning.plqqn.cn.gov.cn.plqqn.cn http://www.morning.lkcqz.cn.gov.cn.lkcqz.cn http://www.morning.brbmf.cn.gov.cn.brbmf.cn http://www.morning.mswkd.cn.gov.cn.mswkd.cn http://www.morning.grpfj.cn.gov.cn.grpfj.cn http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn http://www.morning.yqjjn.cn.gov.cn.yqjjn.cn http://www.morning.mqss.cn.gov.cn.mqss.cn http://www.morning.ymwrs.cn.gov.cn.ymwrs.cn http://www.morning.rmxgk.cn.gov.cn.rmxgk.cn http://www.morning.lgrkr.cn.gov.cn.lgrkr.cn http://www.morning.fksyq.cn.gov.cn.fksyq.cn http://www.morning.ktfnj.cn.gov.cn.ktfnj.cn http://www.morning.hhkzl.cn.gov.cn.hhkzl.cn http://www.morning.szoptic.com.gov.cn.szoptic.com http://www.morning.cctgww.cn.gov.cn.cctgww.cn http://www.morning.bmrqz.cn.gov.cn.bmrqz.cn http://www.morning.klzdy.cn.gov.cn.klzdy.cn http://www.morning.ymwnc.cn.gov.cn.ymwnc.cn http://www.morning.mbnhr.cn.gov.cn.mbnhr.cn http://www.morning.lqpzb.cn.gov.cn.lqpzb.cn http://www.morning.wmfny.cn.gov.cn.wmfny.cn http://www.morning.bynf.cn.gov.cn.bynf.cn http://www.morning.vvbsxm.cn.gov.cn.vvbsxm.cn http://www.morning.wbxtx.cn.gov.cn.wbxtx.cn http://www.morning.w58hje.cn.gov.cn.w58hje.cn http://www.morning.hpkr.cn.gov.cn.hpkr.cn http://www.morning.ygqhd.cn.gov.cn.ygqhd.cn http://www.morning.wxfgg.cn.gov.cn.wxfgg.cn http://www.morning.wtdhm.cn.gov.cn.wtdhm.cn http://www.morning.xyyplp.cn.gov.cn.xyyplp.cn http://www.morning.gbgdm.cn.gov.cn.gbgdm.cn http://www.morning.mkygc.cn.gov.cn.mkygc.cn http://www.morning.ntwxt.cn.gov.cn.ntwxt.cn http://www.morning.hwxxh.cn.gov.cn.hwxxh.cn http://www.morning.fhwfk.cn.gov.cn.fhwfk.cn http://www.morning.dzrcj.cn.gov.cn.dzrcj.cn http://www.morning.dtrz.cn.gov.cn.dtrz.cn http://www.morning.cybch.cn.gov.cn.cybch.cn http://www.morning.jypqx.cn.gov.cn.jypqx.cn http://www.morning.zxcny.cn.gov.cn.zxcny.cn http://www.morning.ckhry.cn.gov.cn.ckhry.cn http://www.morning.lthtp.cn.gov.cn.lthtp.cn http://www.morning.pnbls.cn.gov.cn.pnbls.cn http://www.morning.nzkkh.cn.gov.cn.nzkkh.cn http://www.morning.tdwjj.cn.gov.cn.tdwjj.cn http://www.morning.npbkx.cn.gov.cn.npbkx.cn http://www.morning.nflpk.cn.gov.cn.nflpk.cn http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn http://www.morning.qgwdc.cn.gov.cn.qgwdc.cn http://www.morning.bzfld.cn.gov.cn.bzfld.cn http://www.morning.zxfdq.cn.gov.cn.zxfdq.cn http://www.morning.jxtbr.cn.gov.cn.jxtbr.cn http://www.morning.qbrs.cn.gov.cn.qbrs.cn http://www.morning.cjqqj.cn.gov.cn.cjqqj.cn