Advertisement
askarulytarlan

567c

Aug 31st, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. map<int, int > r, l;
  6. int n, k, ans, a[200500];
  7. int main(){
  8. cin >> n >> k;
  9. for(int i = 0; i < n; i++){
  10. cin >> a[i];
  11. r[a[i]]++;
  12. cout << r[a[i]] << " ";
  13. }
  14. cout << endl;
  15. for(int i = 0; i < n; i++){
  16. if(a[i] % k != 0){
  17. l[a[i]]++;
  18. continue;
  19. }
  20. ans += l[a[i] / k] * (r[a[i] * k] - l[a[i] * k]);
  21. l[a[i]]++;
  22. cout << l[a[i]] << " ";
  23. }
  24. cout << ans;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement