版本比较
【考前复习】个人团队文件保存内容登记
标题
增加 1 行删除 1 行
11个人团队文件保存内容登记【考前复习】个人团队文件保存内容登记正文
增加 134 行删除 1 行
1234567193 行未改动全部展开2012022032042042052062072082092102112122132142152162172182192202212222232242252262272 行未改动230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348描述内容自团队:[https://www.luogu.com.cn/team/103072#main](https://www.luogu.com.cn/team/103072#main)
luogu.me记得手动更新\专栏双站快速跳转:[专栏](https://www.luogu.com.cn/article/0hpegxdh)/[luogu.me专栏](https://www.luogu.me/article/0hpegxdh)>$该文章仅用于个人算法模板保存内容和快速检索与资源共享$
193 行未改动全部展开###### 个人0份- ?### 个人电子?份- [P8306](https://www.luogu.com.cn/record/252320328)别问我为什么代码和有些人一样。。。## **!模板:Title** ## **!计数dp**### 课程内容:- https://www.luogu.com.cn/training/919293#problems- https://vjudge.net/contest/774596#problem
\ ## **!树状数组**### 课程内容:- https://xinyoudui.com/courses/1708/all/#/pages/62123- https://vjudge.net/contest/779975### 官方1组- PPT### 个人1份- 树状数组模板(团队文件)### 个人电子?份- 见提交记录 ## **!模板:Title**### 课程内容:- xinyoudui.com/?- vjudge.net/?### 官方2组- ?2 行未改动### 个人?份- ?### 个人电子?份- ?
# ----------春季内容-----------## ★【考试技巧重点】STL与常数优化(考前可复习)### 快读快写- 好吧,其实约等于快读慢写```cpp//P10815 差一点AC代码#include<bits/stdc++.h>using namespace std;int n;long long sum;inline void read(int &x){ bool neg=0; x=0; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')neg=true; ch=getchar(); } while(ch>='0'&&ch<='9'){ if(neg)x=x*10+('0'-ch); else x=x*10+(ch-'0');; ch=getchar(); }}inline void write(int x){ bool neg = false; if (x < 0) { neg = true; putchar('-'); } static int sta[40]; int top = 0; do { sta[top++] = x % 10; x /= 10; } while (x); if (neg) while (top) putchar('0' - sta[--top]); else while (top) putchar('0' + sta[--top]);}int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); read(n); for(int i=1;i<=n;i++){ int x; read(x); // cout<<x<<'\n'; sum+=x; } write(sum);}```- 小灶:在有些题getchar()过不了,可以用getchar_unlocked()如[P10815](https://www.luogu.com.cn/problem/P10815),但不建议,有的编译器不行- [P10815 AC代码](https://www.luogu.com.cn/record/268878441)(其实就是在上面代码的基础上 开头加了一个`#define getchar() getchar_unlocked()`)### 【考试技巧重点】★常见常数优化(卡常)- 关闭同步流```cpp ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);//0可以用null false等替代```- ++i 代替 i++```cpp// for等使用++i会比i++快,原因不说了,约能快0.5X//例for(int i=1;i<=n;++i){ read(n);}```- 使用用位运算代替四则运算\ 例: ```cppx*10 => (x<<3)+(x<<2);x*8 => x<<3;x/2 => x>>1;```- emplace()\ emplace()代替push\ emplace_back()代替push_back() 可以加速
## 内容未完待续,团队文件里放了STL和常数优化PPT、代码,这些技巧很重要,而且不难
# 其它## 最长上升子序列- <https://www.luogu.com.cn/problem/B3637#ide>## 快速幂qpow- [P1226](https://www.luogu.com.cn/problem/P1226#ide)```cpp#include<iostream>using namespace std;long long a,b,p;long long qp(long long a,long long b){ long long ans=1,t=a; while(b>0){ if(b&1){ ans*=t; ans%=p; } t*=t; t%=p; b>>=1; } return ans;} int main(){ cin>>a>>b>>p; long long ans=qp(a,b); ans=ans%p; printf("%lld^%lld mod %lld=%lld",a,b,p,ans); return 0;}```