#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pr pair
#define vct vector
#define ins insert
#define pb push_back
#define sz(x) ((int)(x.size()))
const int N = 1e6 + 5;
int b[N];
int c[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k; cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) b[a[i]]++;
for (int i = 1; i < N; i++){
if (i <= k) continue;
for (int j = i; j + k < N; j += i) c[j+k] += b[i];
}
int cnt = 0;
for (int i = 0; i < n; i++){
if (a[i] > k) cnt++;
}
for (int i = 0; i < n; i++){
if (a[i] == k){
cout << c[a[i]]+cnt << ' ';
}else{
cout << c[a[i]] << ' ';
}
}
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
6484 KB |
Output is correct |
2 |
Correct |
14 ms |
5672 KB |
Output is correct |
3 |
Correct |
30 ms |
7248 KB |
Output is correct |
4 |
Correct |
87 ms |
8704 KB |
Output is correct |
5 |
Incorrect |
33 ms |
8640 KB |
Output isn't correct |
6 |
Incorrect |
65 ms |
10188 KB |
Output isn't correct |
7 |
Correct |
29 ms |
8668 KB |
Output is correct |
8 |
Correct |
29 ms |
8652 KB |
Output is correct |
9 |
Correct |
70 ms |
10072 KB |
Output is correct |
10 |
Correct |
62 ms |
9960 KB |
Output is correct |