Submission #1265682

#TimeUsernameProblemLanguageResultExecution timeMemory
1265682goulthenSpiderman (COCI20_spiderman)C++20
21 / 70
325 ms16880 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second

const int MAXN = 2e5 + 10;
int a[MAXN], ans[1000001], cnt[1000001];


int32_t main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int n,k;cin >> n >> k;
	rep(i,1,n) cin >> a[i];
	rep(i,1,n) cnt[a[i]]++;

	rep(y,1,1000) {
		rep(i,1,n) {
			if (a[i]%y==k) ans[a[i]]+=cnt[y];
		}
	}

	rep(i,1,n) {
		if (a[i] > 1000) {
			for (int y = k; y <= 1000001; y += a[i]) {
				ans[y]++;
			}
		}
	}

	rep(i,1,n) cout << ans[a[i]] << " \n"[i==n];
	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...