跳到正文

题解

题解:P15430 [蓝桥杯 2025 国 Python B] 等差数列计数

neo20131118约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年2月25日
收录
2026年8月13日
更新
2026年11月11日
篇幅
约 1 分钟
题目
P15430

版本

  1. v1当前

按公差分类讨论(目前只考虑递增)。

公差为11的:(1,2,3)、(2,3,4)、…、(2023,2024,2025)(1,2,3)、(2,3,4)、\dots、(2023,2024,2025),共20232023个。

公差为22的:(1,3,5)、(2,4,6)、…、(2021,2023,2025)(1,3,5)、(2,4,6)、\dots、(2021,2023,2025),共20212021个。

公差为33的:(1,4,7)、(2,5,8)、…、(2019,2022,2025)(1,4,7)、(2,5,8)、\dots、(2019,2022,2025),共20192019个。

以后,公差每增加11,个数就减少22个。总共有1+3+5+⋯+2023=10122=10241441+3+5+\dots+2023=1012^2=1024144个。

但是!(1,2,3)(1,2,3)和(3,2,1)(3,2,1)是不同的等差数列!!!

所以真正的答案是1024144×2=20482881024144\times 2=2048288。

C++
#include<bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	cout<<"2048288";
    return 0;
}
原文