-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfraction.cpp
47 lines (44 loc) · 978 Bytes
/
fraction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("fraction.in");
ofstream fout("fraction.out");
int main()
{
struct nums
{
long long x;
long long y;
};
while(true)
{
long long k;
fin >> k;
if (fin.eof())
{
break;
}
vector<nums> a;
for (long long y = k + 1; y <= 2 * k; ++y)
{
if ((k * y) % (y - k) == 0)
{
long long x = (k * y) / (y - k);
nums temp{x, y};
a.push_back(temp);
}
}
int size = a.size();
fout << size << '\n';
for (int i = 0; i <= size - 1; ++i)
{
fout << "1/" << k << " = 1/" << a[i].x << " + 1/" << a[i].y << '\n';
}
}
}