跳到正文

题解

题解:P12345 [蓝桥杯 2025 省 A 第二场] 双子星的讯息

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

文章信息

发布
2025年4月26日
收录
2025年12月12日
更新
2026年11月22日
篇幅
约 1 分钟
题目
P12345

版本

  1. v1当前

题意:

有多少个 nn 满足 n+20255202n+20255202 与 n+10244201n+10244201 均为完全平方数。

思路:

由 (a2−b2=20255202−10244201=10011001)( a^2 - b^2 = 20255202 - 10244201 = 10011001 ), 设 dd 为 1001100110011001 的因数,则需满足:

d+10011001d≥9002d+\frac{10011001}{d}\geq9002\quad and 10011001d−d≥6402{\frac{10011001}{d}-d}\geq6402

结合以上可得d≤1299d \leq 1299。

之后使用代码枚举 10011001≤129910011001≤1299 的因数数量即可。

Code:

C++
#include<bits/stdc++.h>
using namespace std;
int ans;
int main()
{
    const int N=10011001;
    for(int d=1;d<=1299;d++)
	{
        if(N%d==0) ans++;
    }
    cout << ans;
    return 0;
}
原文
存档评论1 条抓取于