#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
using namespace std;
void solve(){
int n,k; cin >> n >> k;
int arr[n+1];
map<int, int> num;
map<int, int> ans;
set<int> fork;
for(int i=1; i<=n; i++){
cin >> arr[i];
if(arr[i]>k){
num[arr[i]]++;
fork.insert(arr[i]);
}
}
ans[k]=fork.size();
for(auto p:num){
int div=p.st-k;
for(int i=1; i*i<=div; i++){
if(i*i==div) ans[p.st]+= num[i];
else if(div%i==0){
ans[p.st]+= num[div/i] + num[i];
}
}
}
for(int i=1; i<=n; i++) cout << ans[arr[i]] << " ";
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
5 ms |
856 KB |
Output isn't correct |
3 |
Incorrect |
36 ms |
2388 KB |
Output isn't correct |
4 |
Incorrect |
86 ms |
4496 KB |
Output isn't correct |
5 |
Incorrect |
598 ms |
22120 KB |
Output isn't correct |
6 |
Incorrect |
701 ms |
22240 KB |
Output isn't correct |
7 |
Correct |
750 ms |
27984 KB |
Output is correct |
8 |
Correct |
749 ms |
28168 KB |
Output is correct |
9 |
Incorrect |
740 ms |
28964 KB |
Output isn't correct |
10 |
Incorrect |
773 ms |
28996 KB |
Output isn't correct |