Advertisement
ivnikkk

Untitled

Jul 20th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #define debug(tl) cerr<<#tl<<' '<<tl<<'\n';
  3. #include "bits/stdc++.h"
  4. using namespace std;
  5. #define all(d) d.begin(), d.end()
  6. const int N = 1e6 + 1;
  7. int cnt[N] = {};
  8. int cnt2[N] = {};
  9. signed main() {
  10. #ifdef _DEBUG
  11.     freopen("input.txt", "r", stdin);
  12.     freopen("output.txt", "w", stdout);
  13. #endif
  14.     ios_base::sync_with_stdio(false);
  15.     cin.tie(nullptr);
  16.     cout.tie(nullptr);
  17.     int n;
  18.     cin >> n;
  19.     vector<int> a(n);
  20.     for (int i = 0; i < n; i++) {
  21.         cin >> a[i];
  22.         cnt[a[i]]++;
  23.         //cnt2[a[i]]++;
  24.     }
  25.     vector<int> b = a;
  26.     sort(all(a));
  27.     a.resize(unique(all(a)) - a.begin());
  28.     n = (int)a.size();
  29.     int to = a.back();
  30.     for (int i = 0; i < n; i++) {
  31.         int pl = cnt[a[i]];
  32.         for (int j = a[i]; j <= to; j += a[i]) {
  33.             cnt2[j] += cnt[a[i]];
  34.         }
  35.     }
  36.     for (int i = 0; i < (int)b.size(); i++) {
  37.         cout << cnt2[b[i]] - 1 << '\n';
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement