#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
void solve(){
int n,k;cin >> n >> k;
int arr[n],cnt[N],bigger[N];
memset(cnt , 0 , sizeof(cnt));
memset(bigger , 0 , sizeof(bigger));
for(int i = 0;i<n;i++){
cin >> arr[i];
cnt[arr[i]]++;
bigger[arr[i]]++;
}
for(int i = N-2;i>=0;i--){
bigger[i] += bigger[i+1];
}
for(int i = 0;i<n;i++){
int ans = 0;
//bigger
if(arr[i] == k)ans = bigger[arr[i]+1];
//smaller
int temp = arr[i] - k;
for(int i = 1;i*i<=temp;i++){
if(temp % i == 0){
if(i > k)ans += cnt[i];
if((temp/i) > k)ans += cnt[temp / i];
}
}
cout << ans << " ";
}
cout << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
8540 KB |
Output isn't correct |
2 |
Incorrect |
11 ms |
8284 KB |
Output isn't correct |
3 |
Incorrect |
269 ms |
8856 KB |
Output isn't correct |
4 |
Incorrect |
775 ms |
10408 KB |
Output isn't correct |
5 |
Incorrect |
309 ms |
8784 KB |
Output isn't correct |
6 |
Incorrect |
897 ms |
10320 KB |
Output isn't correct |
7 |
Incorrect |
353 ms |
8784 KB |
Output isn't correct |
8 |
Incorrect |
351 ms |
8696 KB |
Output isn't correct |
9 |
Incorrect |
1026 ms |
10148 KB |
Output isn't correct |
10 |
Incorrect |
1022 ms |
10272 KB |
Output isn't correct |