fork(4) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long k;
  6. cin >> k;
  7. // b == k*a/(a-k) == k+k*k/(a-k)
  8. set< pair<long long,long long> > S;
  9. vector< pair<long long,int> > P;
  10. int k2 =k;
  11. for(int i =2; i*i <= k2; i++) if(k2%i == 0) {
  12. int x =0;
  13. while(k2%i == 0) {k2 /=i; x++;}
  14. P.push_back(make_pair(i,2*x));}
  15. if(k2 > 1) P.push_back(make_pair(k2,2));
  16. vector<long long> D(1,1);
  17. for(int i =0; i < P.size(); i++) {
  18. int N =D.size();
  19. for(int j =0; j < N; j++) {
  20. long long d =D[j];
  21. for(int l =1; l <= P[i].second; l++) {
  22. d *=P[i].first;
  23. D.push_back(d);}
  24. }
  25. }
  26. for(int i =0; i < D.size(); i++)
  27. S.insert(make_pair(k*k/D[i]+k,D[i]+k));
  28.  
  29. cout << S.size() << "\n";
  30. for(auto it =S.begin(); it != S.end(); it++)
  31. cout << it->first << " " << it->second << "\n";
  32. return 0;}
Success #stdin #stdout 0s 3436KB
stdin
2
stdout
3
3 6
4 4
6 3