Advertisement
HaciyevAlik

d

Nov 1st, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. using ll = long long;
  5. using ld = long double;
  6. #define ff first
  7. #define ss second
  8. const int INF = 1e9;
  9.  
  10. int f[300000];
  11. int mp[1000000];
  12.  
  13. void solve(){
  14. int n,k; cin >> n >> k;
  15. int h[n+1];
  16. set<int> s;
  17. for(int i = 1;i<=n;++i){
  18. cin >> h[i];
  19. s.insert(h[i]);
  20. mp[h[i]]++;
  21. }
  22. for(auto i = s.begin(); i != s.end(); i++){
  23. ll cur = *i;
  24. for(auto j = s.begin(); j != s.end();j++){
  25. ll cur2 = *j;
  26. if(cur == cur2){
  27. continue;
  28. }
  29. if(cur % cur2 == k){
  30. f[cur] += mp[cur2];
  31. }
  32. }
  33. }
  34. for(int i = 1;i<=n;++i){
  35. cout << f[h[i]] << " ";
  36. }
  37. }
  38.  
  39. int main(){
  40. ios::sync_with_stdio(false); cin.tie(0);
  41. int t = 1; //cin >> t;
  42. while(t--){
  43. solve();
  44. cout << "\n";
  45. }
  46. return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement