版本比较
L5-f2021ljh模拟赛 题解
正文
增加 28 行删除 28 行
8 行未改动91011121313141515161717181919202121222323242525262728293031323334353334353637383920 行未改动606162636464656666676868697070717273747576777879807879808182838422 行未改动10710810911011111111211311311411511511611711711811911912012112212312412512612712812912712812913013113213336 行未改动1701711721731741741751761761771781781798 行未改动考试结束后又加上了(~~270->260 警钟长鸣~~)
## T1 [CF1542B](https://www.luogu.com.cn/problem/CF1542B)
原题可以转化成n是否能写成$ a^x+yb $
显然,若本次操作为乘法,则结果变为$ a^{x+1}+ayb $
由于y是任意选取的,所以这个数仍是$ a^x+yb $的形式
若本次操作为加法,则结果变为$ a^{x}+(y+1)b $,同样是$ a^x+yb $的形式
将式子转为$n-a^x \equiv 0 (\bmod\, b)$枚举x即可
记得特判$a=1$
```cpp /* * @Author: 2019yyy * @Date: 2022-10-13 20:30:39 * @LastEditors: 2019yyy * @LastEditTime: 2022-10-13 22:00:56 * @FilePath: \code\codeBiulders\460A.cpp * @Description: * * I love Chtholly forever * @Description: * * I love Chtholly forever */#include<bits/stdc++.h>using namespace std;#define int long long20 行未改动} ``` ## T2 [CF1016D](https://www.luogu.com.cn/problem/CF1015D)
显然把步数平均是最好选择,因此我们每次走$ \lfloor \frac{s}{k} \rfloor$是最优的,多出来的$ s\,\bmod \, k$平均分配在前$ s\,\bmod \, k$步上
如果中间超过了上限就输出NO
另外要特判步数摊不开,也就是$k \geq s+1$时,也是NO
```cpp /* * @Author: 2019yyy * @Date: 2022-10-13 21:07:47 * @LastEditors: 2019yyy * @LastEditTime: 2022-10-13 21:15:58 * @FilePath: \code\codeforces\460B.cpp * @Description: * * I love Chtholly forever * @Description: * * I love Chtholly forever */#include<bits/stdc++.h>using namespace std;#define int long long22 行未改动} ``` ## T3 [CF1681D](https://www.luogu.com.cn/problem/CF1681D)
纯dfs连样例都过不去,所以我们要加优化
每次最小乘$2$($x=1$例外),所以最多进行$log \frac{2e9}{x}$次运算
然后我们考虑IDA*:每次增加一位数或不增加,我们可以统计出x的位数t,那么估价函数为f(x)=n-t
dfs后别忘了回溯,重新统计位数(~~我在这卡了20分钟~~)
```cpp /* * @Author: 2019yyy * @Date: 2022-10-13 21:20:47 * @LastEditors: 2019yyy * @LastEditTime: 2022-10-13 21:29:01 * @FilePath: \code\codeBiulders\460C.cpp * @Description: * * I love Chtholly forever * @Description: * * I love Chtholly forever */#include<bits/stdc++.h>using namespace std;#define int long long36 行未改动 cout<<-1<<'\n'; return 0;} ```
## T4
[CF1628D1](https://www.luogu.com.cn/problem/CF1628D1)
我还不会,待更