using namespace std;
#include <iostream>
#include <unordered_map>
#include <cmath>
unordered_map<int,int> us;
int zero = 0;
int arr[300005];
int ans[300005];
int main() {
int N,K;
cin >> N >> K;
for(int i = 0;i < N;i++) {
int cur;
cin >> cur;
arr[i] = cur;
us[cur]++;
if(cur > K) {
zero++;
}
}
for(int i = 0;i < N;++i) {
int cur = arr[i] - K;
if(cur < 0) {
continue;
}else if(cur == 0) {
ans[i] = zero;
continue;
}
for(int j = 1;j <= sqrt(cur);++j) {
if(cur % j == 0) {
int counter = cur / j;
if(j > K) ans[i] += us[j];
if(counter > K && counter != j) ans[i] += us[counter];
}
}
}
for(int i = 0;i < N;i++) {
cout << ans[i] << " ";
}
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
768 KB |
Output is correct |
2 |
Correct |
13 ms |
640 KB |
Output is correct |
3 |
Correct |
388 ms |
1912 KB |
Output is correct |
4 |
Correct |
1129 ms |
4216 KB |
Output is correct |
5 |
Incorrect |
519 ms |
7908 KB |
Output isn't correct |
6 |
Incorrect |
1473 ms |
9908 KB |
Output isn't correct |
7 |
Correct |
618 ms |
13120 KB |
Output is correct |
8 |
Correct |
617 ms |
13168 KB |
Output is correct |
9 |
Correct |
1688 ms |
15120 KB |
Output is correct |
10 |
Correct |
1641 ms |
14928 KB |
Output is correct |