#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) != i and (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();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
8280 KB |
Output is correct |
2 |
Correct |
11 ms |
8280 KB |
Output is correct |
3 |
Correct |
269 ms |
8788 KB |
Output is correct |
4 |
Correct |
776 ms |
10668 KB |
Output is correct |
5 |
Incorrect |
309 ms |
8824 KB |
Output isn't correct |
6 |
Incorrect |
890 ms |
10348 KB |
Output isn't correct |
7 |
Correct |
355 ms |
8664 KB |
Output is correct |
8 |
Correct |
352 ms |
8676 KB |
Output is correct |
9 |
Correct |
1029 ms |
10204 KB |
Output is correct |
10 |
Correct |
1025 ms |
10476 KB |
Output is correct |