fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. const ll MAX = 1e6 + 5;
  6. bool is_prime[MAX];
  7. ll sum_d[MAX];
  8. void sang(ll n){
  9. fill(is_prime, is_prime + n + 1, true);
  10. is_prime[0] = false;
  11. is_prime[1] = false;
  12. for(ll p = 2; p * p <= n; p++){
  13. if(is_prime[p]){
  14. for(ll i = p * p; i <= n; i+= p){
  15. is_prime[i] = false;
  16. }
  17. }
  18. }
  19. for(ll i = 1; i <= n; i++){
  20. for(ll j = i; j <= n; j += i){
  21. sum_d[j] += i;
  22. }
  23. }
  24. }
  25.  
  26. int main(){
  27. ios_base::sync_with_stdio(false);
  28. cin.tie(NULL);cout.tie(NULL);
  29.  
  30. sang(MAX);
  31. ll n;
  32. cin >> n;
  33.  
  34. while(n--){
  35. ll a;
  36. cin >> a;
  37. if(2 * a <= sum_d[a]){
  38. cout << "1" << "\n";
  39. }
  40. else{
  41. cout << "0" << "\n";
  42. }
  43. }
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0.04s 12360KB
stdin
Standard input is empty
stdout
Standard output is empty