标题
增加 1 行删除 1 行
1个人团队文件保存内容登记1【考前复习】个人团队文件保存内容登记
正文
增加 115 行删除 0 行
229 行未改动全部展开230231232233229 行未改动全部展开### 个人?份- ?### 个人电子?份- ?229 行未改动全部展开230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348229 行未改动全部展开### 个人?份- ?### 个人电子?份- ?# ----------春季内容-----------## ★【考试技巧重点】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]);elsewhile (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()`)### 【考试技巧重点】★常见常数优化(卡常)- 关闭同步流```cppios::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;}```