Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define NMAX 10010
- using namespace std;
- ifstream fin("armonica.in");
- ofstream fout("armonica.out");
- struct fractie
- {
- long long x,y;
- };
- fractie v[NMAX];
- long long nr;
- int main()
- {
- long long sf = 1;
- long long max = 1;
- long long d = 2;
- long long p = 1;
- long long n;
- fin>>nr;
- if(nr%2==0)
- n = nr/2;
- else
- n = nr;
- v[0].x = 1;
- v[0].y = 1;
- while(n>1)
- {
- p = 1;
- while(n%d==0)
- {
- p*=d;
- n/=d;
- }
- sf = max;
- while(p>1)
- {
- v[sf].x = v[0].x * p;
- v[sf].y = v[0].y;
- sf++;
- for(int i = 1;i<max;i++)
- {
- v[sf].x = v[i].x*p;
- v[sf].y = v[i].y;
- sf++;
- v[sf].x = v[i].x;
- v[sf].y = v[i].y*p;
- sf++;
- }
- p/=d;
- }
- d++;
- if(d*d>n)
- d = n;
- max = sf;
- }
- fout<<2*sf-1<<'\n';
- fout<<nr<<" "<<nr<<'\n';
- for(int i=1;i<sf;i++)
- {
- fout<<nr*(v[i].x+v[i].y)/(2*v[i].x)<<" "<<nr*(v[i].x+v[i].y)/(2*v[i].y)<<'\n';
- fout<<nr*(v[i].x+v[i].y)/(2*v[i].y)<<" "<<nr*(v[i].x+v[i].y)/(2*v[i].x)<<'\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement