Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #define debug(tl) cerr<<#tl<<' '<<tl<<'\n';
- #include "bits/stdc++.h"
- using namespace std;
- #define all(d) d.begin(), d.end()
- const int N = 1e6 + 1;
- int cnt[N] = {};
- int cnt2[N] = {};
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int n;
- cin >> n;
- vector<int> a(n);
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- cnt[a[i]]++;
- //cnt2[a[i]]++;
- }
- vector<int> b = a;
- sort(all(a));
- a.resize(unique(all(a)) - a.begin());
- n = (int)a.size();
- int to = a.back();
- for (int i = 0; i < n; i++) {
- int pl = cnt[a[i]];
- for (int j = a[i]; j <= to; j += a[i]) {
- cnt2[j] += cnt[a[i]];
- }
- }
- for (int i = 0; i < (int)b.size(); i++) {
- cout << cnt2[b[i]] - 1 << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement