Advertisement
Saleh127

UVA 10976

Dec 9th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll k,x,y,j,i,l;
  11. while(scanf("%lld",&k)!=EOF)
  12. {
  13. l=0;
  14.  
  15. ll a[k+5],b[k+5];
  16. ///1/k=1/x+1/y is equal to 1/x=1/k-1/y==(k*y)/(y-k);
  17. ///y=i;
  18. ///x=(i*k)%(i-k);
  19. for(i=k+1;i<=(2*k);i++)
  20. {
  21. if((i*k)%(i-k)==0)
  22. {
  23. a[l]=(i*k)/(i-k);
  24. b[l]=i;
  25. l++;
  26. }
  27. }
  28. printf("%lld\n",l);
  29. for(i=0;i<l;i++)
  30. {
  31. printf("1/%d = 1/%d + 1/%d\n",k,a[i],b[i]);
  32. }
  33. }
  34.  
  35.  
  36. return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement