版本比较
暑假第21节课总结
标题
增加 1 行删除 1 行
11暑假第20节课总结暑假第21节课总结正文
增加 183 行删除 60 行
1234561231011121314456789171819102122111224252627282930313233343536371314154016171819202122232425262728293031323334353637383940414243444546474849505152535451525354555657585960616263646555565758695960616263646566676869707172737475767778798081828384858687888990919293949576777896978081828384858687888998991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182 行未改动# 前言马上就除夕了,在这里预祝大家新年快乐,万事如意。
> $2024,乘风破浪!$
# 考试情况| | 模拟赛分数 | 改题用时 || :----------: | :----------: | :----------: || [T1](https://www.luogu.com.cn/problem/P1241) | $0$ | $3 \ min$ || [T2](https://www.luogu.com.cn/problem/P1334) | $100$ | $0\ min$ || [T3](https://www.luogu.com.cn/problem/P3948) | $0$ | $10\ min$ || [T4](https://www.luogu.com.cn/problem/P9094) | $0$ | $10\ min$ || [T5](https://www.luogu.com.cn/problem/P9094) | $30$ | $10\ min$ || [T1](https://www.luogu.com.cn/problem/P2669) | $100$ | $0 \ min$ || [T2](https://www.luogu.com.cn/problem/P7909) | $80$ | $8\ min$ || [T3](https://www.luogu.com.cn/problem/P11229) | $60$ | $15\ min$ || [T4](https://www.luogu.com.cn/problem/P9748) | $100$ | $0\ min$ |
# 题目总结## T1### 错误原因将栈内括号弹出时将没有匹配的左括号也弹出了。
```cpp```## T2「P7909 [CSP-J 2021] 分糖果」
错误出在```cpp```
的 ` ` 处。
### 正确思路
### 正确代码```cpp```
## T2### 错误原因我没有想到优化的办法
### 错误代码```cpp#include<bits/stdc++.h>using namespace std;int main(){ int n,l,r,maxx=0; cin>>n>>l>>r; for(int i=l;i<=r;i++) { int cnt=i; while(cnt>=n) { cnt-=n; } maxx=max(maxx,cnt); } cout<<maxx; return 0;}```
### 正确思路题目让我们输出奖励最大的就是[l~r]之间的一个数%n中的最大的答案,最大的一定是n-1,可是只有大于等于n的才有可能,我们先看l%n是最小的,如果+长度个1,大于n-1,那就肯定出现过n-1,输出n-1就行了;可如果加完了还没到n-1的话,那他自己现在的数就是最大的;
### 正确代码```cpp#include<bits/stdc++.h>using namespace std;int main(){ int n,l,r,maxx=0; cin>>n>>l>>r; int len=r-l+1; cout<<min(n-1,l%n+len-1); return 0;}```
## T3
### 错误原因
### 错误代码```cpp```
### 正确思路
### 正确代码```cpp```
## T4### 错误原因这是昨天的第三题,忘记了dfs怎么写所以只拿了60分。
### 错误代码```cpp#include<bits/stdc++.h>using namespace std;int main(){ int T; cin>>T; while(T--) { int n; cin>>n; if(n%7==0) { for(int i=1;i<=n/7;i++) { cout<<"8"; } cout<<endl; } if(n%7==1) { cout<<"10"; for(int i=1;i<n/7;i++) { cout<<"8"; } cout<<endl; } } return 0;}```
### 正确思路先看一下n是个位数吗?如果是2以下的就输出-1,如果是等于2的就输出1,如果是等于3的就输出7,如果是等于4的就输出4,如果是等于5的就输出2,如果是等于6的就输出6。
### 正确代码```cpp```n如果不是个位数,如果是n%7==0的就输出n%7个8;如果是n%7==1的话就先输出10在输出n%7-1个8;如果是n%7==2的话就先输出1在输出n%7个8;如果是n%7==3的话就比较特殊要先判断一下这个数是不是10,是的话就输出22;如果是n%7==4的话就先输出20在输出n%7-1个8;如果是n%7==5的话就先输出2在输出n%7个8;如果是n%7==6的话就先输出6在输出n%7个8;
## T5### 错误原因
### 错误代码```cpp```
### 正确思路
### 正确代码```cpp#include<bits/stdc++.h>using namespace std;int main(){ int T; cin>>T; while(T--) { int n; cin>>n; if(n<=7) { if(n<2) { cout<<-1; } else if(n==2) { cout<<1; } else if(n==3) { cout<<7; } else if(n==4) { cout<<4; } else if(n==5) { cout<<2; } else if(n==6) { cout<<6; } else { cout<<8; } } else { if(n%7==0) { for(int i=1;i<=n/7;i++) { cout<<"8"; } } else if(n%7==1) { cout<<"10"; for(int i=1;i<n/7;i++) { cout<<"8"; } } else if(n%7==2) { cout<<"1"; for(int i=1;i<=n/7;i++) { cout<<"8"; } } else if(n%7==3) { if(n/7>=2) { cout<<"200"; for(int i=1;i<n/7-1;i++) { cout<<"8"; } } else { cout<<"22"; for(int i=1;i<n/7;i++) { cout<<"8"; } } } else if(n%7==4) { cout<<"20"; for(int i=1;i<n/7;i++) { cout<<"8"; } } else if(n%7==5) { cout<<"2"; for(int i=1;i<=n/7;i++) { cout<<"8"; } } else if(n%7==6) { cout<<"6"; for(int i=1;i<=n/7;i++) { cout<<"8"; } } } cout<<endl; } return 0;}```
# End发挥失常了,下次继续。2 行未改动