Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- #define ff first
- #define ss second
- const int INF = 1e9;
- int f[300000];
- int mp[1000000];
- void solve(){
- int n,k; cin >> n >> k;
- int h[n+1];
- set<int> s;
- for(int i = 1;i<=n;++i){
- cin >> h[i];
- s.insert(h[i]);
- mp[h[i]]++;
- }
- for(auto i = s.begin(); i != s.end(); i++){
- ll cur = *i;
- for(auto j = s.begin(); j != s.end();j++){
- ll cur2 = *j;
- if(cur == cur2){
- continue;
- }
- if(cur % cur2 == k){
- f[cur] += mp[cur2];
- }
- }
- }
- for(int i = 1;i<=n;++i){
- cout << f[h[i]] << " ";
- }
- }
- int main(){
- ios::sync_with_stdio(false); cin.tie(0);
- int t = 1; //cin >> t;
- while(t--){
- solve();
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement