等式

求 1/a + 1/b = 1/n的正数解

设 x = a + n, y = b + n, 原式变为 a * b = n * n

答案微n * n 的约数个数加一之后的一半, 因为n * n 太大不能直接求因子个数需要通过质因子个数求约数个数。

复制代码
 1 #include<bits/stdc++.h>
 2 #define LL long long
 3 #define fi first
 4 #define se second
 5 #define mk make_pair
 6 #define pii pair<int,int>
 7 using namespace std;
 8 
 9 const int N = 1000 + 7;
10 const int M = 100 + 7;
11 const int inf = 0x3f3f3f3f;
12 const LL INF = 0x3f3f3f3f3f3f3f3f;
13 const int mod = 1e9 + 7;
14 
15 
16 LL n, cnt[100], tot;
17 
18 int main() {
19     int T; scanf("%d", &T);
20     while(T--) {
21         tot = 0;
22         memset(cnt, 0, sizeof(cnt));
23         scanf("%lld", &n);
24         for(int i = 2; i * i <= n; i++) {
25             if(n % i == 0) {
26                 while(n % i == 0)
27                     cnt[tot]++, n /= i;
28                 tot++;
29             }
30         }
31         if(n != 1)
32             cnt[tot]++, tot++;
33 
34         for(int i = 0; i < tot; i++)
35             cnt[i] *= 2;
36         LL ans = 1;
37         for(int i = 0; i < tot; i++)
38             ans *= cnt[i] + 1;
39         printf("%lld\n", (ans + 1) / 2);
40     }
41     return 0;
42 }
43 
44 /*
45 */
复制代码

 

posted @   NotNight  阅读(173)  评论(0编辑  收藏  举报
编辑推荐:
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
阅读排行:
· 手把手教你更优雅的享受 DeepSeek
· AI工具推荐:领先的开源 AI 代码助手——Continue
· 探秘Transformer系列之(2)---总体架构
· V-Control:一个基于 .NET MAUI 的开箱即用的UI组件库
· 乌龟冬眠箱湿度监控系统和AI辅助建议功能的实现
点击右上角即可分享
微信分享提示