fork(5) download
  1. #include<bits/stdc++.h>
  2. #define N 10000005
  3. using namespace std;
  4. bool v[N] ;
  5. int sp[N] ;
  6. void primeset(){
  7. for(long long int i = 2; i < N; i += 2)
  8. sp[i] = 2 ;
  9. for(long long int i = 3; i < N; i += 2)
  10. if (!v[i]){
  11. sp[i] = i ;
  12. if(i<=3617) for(int j = i * i; j < N; j += 2 * i)
  13. if (!v[j]){
  14. sp[j] = i ;
  15. v[j] = 1 ;
  16.  
  17. }
  18. }
  19. }
  20.  
  21. long long int factor (long long int n) {
  22. long long int k = 1 ;
  23. int count;
  24. while(n > 1){
  25. count = 0 ;
  26. long long int s= sp[n] ;
  27. while(n % s == 0){
  28. n /= s ;
  29. count++ ;
  30. }
  31. k *= (pow(s,2*count+1) + 1) / (s + 1) ;
  32. }
  33. return k ;
  34. }
  35. int main(){
  36.  
  37. primeset() ;
  38. long long int t;
  39. long long int n ,c ;
  40. scanf("%llu",&t);
  41. while(t--)
  42. {
  43. scanf("%llu",&n);
  44. c=factor(n);
  45. printf("%llu\n",c);
  46. }
  47. return 0 ;
  48. }
Runtime error #stdin #stdout 0.26s 51560KB
stdin
Standard input is empty
stdout
Standard output is empty