fork download
  1. // Life is a race...And I am just a viewer of that race ~ Pari_na_kisu
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. #ifndef ONLINE_JUDGE
  7. #include "DEBUG.h"
  8. #else
  9. #define debug(x)
  10. #define bug(...)
  11. #define ErroR()
  12. #endif
  13.  
  14. #define endl "\n"
  15. using ll = long long;
  16.  
  17. vector <ll> primes;
  18. ll N = 1e8;
  19.  
  20. void bitwise_seive () {
  21. vector <bool> status(N + 2);
  22.  
  23. for (ll i = 2; i < N; i++) {
  24. if (!status[i]) {
  25. primes.push_back (i);
  26. for (ll j = i * i; j <= N; j+= i) {
  27. status[j] = true;
  28. }
  29. }
  30. }
  31. }
  32.  
  33.  
  34. ll get_div_sum_(ll x) {
  35. ll ans = 1;
  36.  
  37. for (auto &i: primes) {
  38. if (i * i > x) break;
  39. if (x % i == 0) {
  40. int e = 0;
  41. ll sum = 1, pow = i;
  42. while (x % i == 0) {
  43. x /= i;
  44. sum += pow;
  45. pow *= i;
  46. // e++;
  47. }
  48. ans *= sum;
  49. }
  50. }
  51.  
  52. if (x > 1) ans *= (x + 1);
  53. return ans;
  54. }
  55.  
  56. int main() {
  57.  
  58. ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  59. ErroR();
  60.  
  61. int t = 1, tc;
  62. cin >> t;
  63.  
  64. auto solve = [&] () -> void {
  65. ll n; cin >> n;
  66.  
  67. cout << get_div_sum_(n) - n << endl;
  68.  
  69. };
  70.  
  71.  
  72. bitwise_seive();
  73. for (tc = 1; tc <= t; tc++) {
  74. solve();
  75. }
  76.  
  77. return 0;
  78. }
  79.  
  80.  
  81.  
  82. /*
  83. cout << "YES\n";
  84. cout << "NO\n";
  85.  
  86. Output:
  87.  
  88.  
  89. */
  90.  
Success #stdin #stdout 1.01s 82184KB
stdin
Standard input is empty
stdout
34634638107104