Advertisement
HaciyevAlik

Spider-man

Oct 31st, 2022
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 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.  
  12. void solve(){
  13.     int n,k; cin >> n >> k;
  14.     int h[n+1];
  15.     set<int> s;
  16.     map<int,int> mp;
  17.     for(int i = 1;i<=n;++i){
  18.         cin >> h[i];
  19.         s.insert(h[i]);
  20.         mp[h[i]]++;
  21.     }
  22.     for(int i : s){
  23.         ll cur = i;
  24.         for(int j : s){
  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