Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- map<int, int > r, l;
- int n, k, ans, a[200500];
- int main(){
- cin >> n >> k;
- for(int i = 0; i < n; i++){
- cin >> a[i];
- r[a[i]]++;
- cout << r[a[i]] << " ";
- }
- cout << endl;
- for(int i = 0; i < n; i++){
- if(a[i] % k != 0){
- l[a[i]]++;
- continue;
- }
- ans += l[a[i] / k] * (r[a[i] * k] - l[a[i] * k]);
- l[a[i]]++;
- cout << l[a[i]] << " ";
- }
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement