fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  4. #define ll long long
  5. const int N = 1e6 + 5;
  6. vector<int>primes;
  7. void sieve()
  8. {
  9. vector<bool> isprime(N, 1);
  10. for(int i = 2; i < N; i++)
  11. {
  12. if(!isprime[i]) continue;
  13. primes.push_back(i);
  14. for(int j = 2*i; j < N; j+=i)
  15. isprime[j] = 0;
  16. }
  17. }
  18. void solve()
  19. {
  20. ll n;
  21. cin >> n;
  22. ll ans = 0, x = n;
  23. for(auto p : primes)
  24. {
  25. if((ll)p*p > n) break;
  26. if(x % p == 0)
  27. {
  28. ans++;
  29. while(x % p == 0) x/=p;
  30. }
  31. }
  32. if(x > 1) ans++;
  33. cout << (1LL << ans) - 2 << endl;
  34. }
  35. int main()
  36. {
  37. FAST;
  38. int t = 1;
  39. sieve();
  40. cin >> t;
  41. while (t--) solve();
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
6