版本比较
2025秋训 J赛前 9.6测试题解
正文
增加 15 行删除 9 行
123455678943 行未改动5354555657575859606120 行未改动828384858686878889904 行未改动95969798999910010110210374 行未改动17817918018118218218318418518618718718818919019119219319319419519619719819920020120220220320420520620739 行未改动247248249250250251252253254255256257# 2025秋训 J赛前 9.6测试题解
## A
观察到$n$的取值范围:$n\le10^{12}$ 观察到$n$的取值范围:$n\le10^{12}$故考虑二分。先存储每一个音符的起始节拍,然后 $ \texttt{lowerbound}$即可。注意特判到最后播放完了直接输出$0$即可。
### A Code
43 行未改动```最后还原:```cpp for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int j=1;j<=n;j++) a[i][j]=a[i-1][j]+a[i][j-1]+d[i][j]-a[i-1][j-1]; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++) cout<<a[i][j]%2<<" ";20 行未改动 d[x1][y2+1]--; d[x2+1][y2+1]++; } for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int j=1;j<=n;j++) a[i][j]=a[i-1][j]+a[i][j-1]+d[i][j]-a[i-1][j-1]; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++) cout<<a[i][j]%2<<" ";4 行未改动```
## C
打表+大模拟。 打表+大模拟。容易观察到本题类似于$\texttt{CSP-J\ 2024\ T3}$.
于是就好做了。对于每个数字最后必然会变成固定的几位。
74 行未改动即:
$$\begin{cases}m\times [(1-m)^{n-1}+(1-m)^{n-2}+...], & \text {if $n-1$ is even} \\m\times [(1-m)^{n-1}+(1-m)^{n-2}+...], & \text {if $n-1$ is even} \\\\-m\times [(1-m)^{n-1}+(1-m)^{n-2}+...], & \text{if $n-1$ is odd}\end{cases}$$
观察到 观察到$(1-m)^{n-1}+(1-m)^{n-2}+...=\frac{(1-m)^{n}-(1-m)}{-m}$
故最后得到我们要求的数:$$\begin{cases}-(1-m)^{n}+(1-m), & \text {if $n-1$ is even} \\-(1-m)^{n}+(1-m), & \text {if $n-1$ is even} \\\\(1-m)^{n}-(1-m), & \text{if $n-1$ is odd}\end{cases}$$
即:
$$\begin{cases}(m-1)^{n}-(m-1), & \text {if $n$ is odd} \\(m-1)^{n}-(m-1), & \text {if $n$ is odd} \\\\
(m-1)^{n}+(m-1), & \text{if $n$ is even}\end{cases}$$
39 行未改动
感谢支持!求三连啦~
```字数统计:4213 字符字数统计:4276 字符```
### upd
```upd on 2025/9/14 5:55 修复了markdown排版问题(T4)