云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Problem Description Diophantus of Alexandria was an egypt mathematician living in Alexandria

Problem Description Diophantus of Alexandria was an egypt mathematician living in Alexandria

  • 62 次阅读
  • 3 次下载
  • 2025/5/25 19:27:33

Problem Description Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to inte

gral values. In honor of him, these equations are commonly called diophantine equations. One of the most famous diophantine equation is x^n + y^n = z^n. Fermat suggested that for n > 2, there are no solutions with positive integral values for x, y and z. A proof of this theorem (called Fermat's last theorem) was found only recently by Andrew Wiles. Consider the following diophantine equation: 1 / x + 1 / y = 1 / n where x, y, n ∈ N+ (1)

Diophantus is interested in the following question: for a given n, how many distinct solutions (i. e., solutions satisfying x ≤ y) does equation (1) have? For example, for n = 4, there are exactly three distinct solutions: 1 / 5 + 1 / 20 = 1 / 4 1 / 6 + 1 / 12 = 1 / 4 1/8+1/8=1/4

Clearly, enumerating these solutions can become tedious for bigger values of n. Can you help Diophantus compute the number of distinct solutions for big values of n quickly? Input The first line contains the number of scenarios. Each scenario consists of one line containing a single number n (1 ≤ n ≤ 10^9). Output The output for every scenario begins with a line containing \scenario starting at 1. Next, print a single line with the number of distinct solutions of equation (1) for the given value of n. Terminate each scenario with a blank line. Sample Input 2 4 1260 Sample Output Scenario #1: 3 Scenario #2: 113 题意,给一给 n,问有多少正整数对(x, y)满足 1/x + 1/y = 1/n, (x,y)跟(y,x)是一样的。 大致思路: 设 x=pk, y=qk (gcd(p,q) = 1) 那么 1/x+1/y = 1/pk+1/qk = (p+q)/pqk = 1/n ==> n = pqk/(p+q)... 因为 p,q 互质且 n 为整数。所以 n=p*q*(k/(p+q)).

pq 固定下来,k 也固定了。然后分解质因式 n=p1^r1*p2^r2*...*pt^rt..。枚举每个因子属于 p 还是 q 还是都不属于,同时枚举次数。最后相加起来就是答案。 代码: [cpp] view plaincopyprint? #include #include #include #include #include #include #include #include #include using namespace std; #define MAXN 40000 #define eps (1e-9) #define INF 1000000000 #define abs(x) ((x) > 0? (x): -(x)) #definesqr(x) ((x) * (x)) #define two(x) (1 << (x)) typedef long long LL; int n, tp, tf, ans, pr[MAXN], tn[20]; boolisp[MAXN]; voidmake_primes() { tp = 0; memset(isp, 1, sizeof(isp)); for (int i = 2; i < MAXN; ++i) { if (isp[i]) pr[++tp] = i; for (int j = 1; j <= tp&&pr[j] * i < MAXN; ++j) { isp[pr[j] * i] = false; if (i % pr[j] == 0) break; } } } voidinit() { scanf(\

int x = n; for (int i = 1; i <= tp&&sqr(pr[i]) <= x; ++i) if (x % pr[i] == 0) { tn[++tf] = 0; while (x % pr[i] == 0) { ++tn[tf]; x /= pr[i]; } } if (x > 1) tn[++tf] = 1; ans = 0; } void dg(int x, int p, int q, bool hasp) { if (x == tf + 1) ans += p * q; else { dg(x + 1, p, q, hasp); dg(x + 1, p * tn[x], q, true); if (hasp) dg(x + 1, p, q * tn[x], hasp); } } int main() { make_primes(); int T, ca = 0; scanf(\

{ printf(\return 0; }

搜索更多关于: Problem Description Diophantus 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

Problem Description Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to inte gral values. In honor of him, these equations are commonly called diophantine equations. One of the most famous diophantine equation is x^n + y^n = z^n. Fermat suggested that for n > 2, ther

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com