1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| #include <bits/stdc++.h> using namespace std; const int LEN = 1e6 + 50; int n, arr[LEN], cnt[LEN], w[LEN];
int main() { cin >> n; for (int i = 1; i <= n; ++i) cin >> arr[i], ++cnt[arr[i]]; for (int i = 1; i <= 1e6; ++i) { for (int j = i; j <= 1e6; j += i) { w[j] += cnt[i]; } } for (int i = 1; i <= n; ++i) { cout << w[arr[i]] - 1 << endl; } return 0; }
|