#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
using namespace std;
#pragma warning(disable:4996)
unsigned long long k, t, t1, t2; vector<pair<unsigned long long, unsigned long long>> v; pair<unsigned long long, unsigned long long> p;
int main() {
for (;;) {
if (scanf("%llu", &k) == EOF)return 0;
t = 2 * k;
for (p.second = k + 1; p.second <= t; ++p.second) {
t1 = k * p.second, t2 = p.second - k; p.first = t1 / t2; if (p.first * t2 == t1)v.emplace_back(p);
}
printf("%llu\n", v.size());
for (unsigned long long i = 0; i < v.size(); ++i)printf("1/%llu = 1/%llu + 1/%llu\n", k, v[i].first, v[i].second);
v.clear();
}
}
UVA 10976 Fractions Again?(暴力,0 ms)
最新推荐文章于 2023-10-27 19:11:30 发布
本文介绍了一段C++代码,该代码用于寻找特定形式的分数表达式的所有整数解。通过输入一个参数k,程序会找出所有满足1/k = 1/x + 1/y形式的整数对(x, y),其中x和y大于0且x不等于y。文章展示了如何使用循环和条件判断来实现这一目标,适合于对数学问题感兴趣或希望了解C++编程技巧的读者。
534

被折叠的 条评论
为什么被折叠?



