fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long int n, maxi, v[65535], a[1000000], cif = 1, putere = 1, r = 1;
  6.  
  7. int main()
  8. {
  9. cin >> n;
  10. for (int i = 1; i <= n; ++i) {
  11. cin >> v[i];
  12. if (v[i] > maxi)
  13. maxi = v[i];
  14. }
  15. a[1] = 1;
  16. while (cif < maxi) {
  17. ++r;
  18. a[r] = cif + 1;
  19. ++putere;
  20. cif += putere;
  21. }
  22. for (int i = 1; i <= n; ++i) {
  23. if (v[i] > a[r])
  24. cout << 0 << ' ';
  25. else {
  26. for (int j = 1; j <= r; ++j)
  27. {
  28. if (a[j] == v[i]) {
  29. cout << 1 << ' ';
  30. break;
  31. }
  32. if (a[j] > v[i]) {
  33. cout << 0 << ' ';
  34. break;
  35. }
  36. }
  37. }
  38. }
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty