fork download
  1. #include "bits/stdc++.h"
  2. #define MAXN 100009
  3. #define INF 1000000007
  4. #define mp(x,y) make_pair(x,y)
  5. #define all(v) v.begin(),v.end()
  6. #define pb(x) push_back(x)
  7. #define wr cout<<"----------------"<<endl;
  8. #define ppb() pop_back()
  9. #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
  10. #define ff first
  11. #define ss second
  12. #define my_little_dodge 46
  13. #define debug(x) cerr<< #x <<" = "<< x<<endl;
  14. using namespace std;
  15.  
  16. typedef long long ll;
  17. typedef pair<int,int> PII;
  18. template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
  19. template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
  20. ll N;int sz;
  21. vector<pair<ll,int> >v;
  22. bool bad(ll x,ll y){
  23. return (x>N/y);
  24. }
  25. vector<ll>ans;
  26. void rec(int pos,ll mul){
  27. if(pos==sz){
  28. ans.pb(mul+N);
  29. return;
  30. }
  31. ll pw=1;
  32. for(int i=0;i<=v[pos].ss;i++){
  33. if(bad(mul,pw))
  34. return;
  35. rec(pos+1,mul*pw);
  36. pw*=v[pos].ff;
  37. }
  38. }
  39. int main(){
  40. int t;
  41. scanf("%d",&t);
  42. assert(1<=t && t<=10);
  43. while(t--){
  44. ll n;
  45. scanf("%lld",&n);N=n;
  46. int b=sqrt(n);
  47. for(int i=2;i<=b;i++)
  48. if(n%i==0){
  49. int cnt=0;
  50. while(n%i==0)
  51. cnt+=2,n/=i;
  52. v.pb(mp(i,cnt));
  53. }
  54. if(n!=1)
  55. v.pb(mp(n,2));
  56. sz=v.size();rec(0,1);
  57. sort(all(ans));
  58. assert(1<=ans.size() && ans.size()<=int(1e7));
  59. printf("%d\n",ans.size());
  60. tr(it,ans)
  61. printf("%lld\n",*it);
  62. v.clear();ans.clear();
  63. }
  64. return 0;
  65. }
Runtime error #stdin #stdout #stderr 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog: prog.cpp:42: int main(): Assertion `1<=t && t<=10' failed.