#include <bits/stdc++.h>
#define all(v) ((v).begin(),(v).end())
using namespace std;
#define int long long
const int mod = 1e9 + 7;
const int mxN = 2e6 + 1;
int a[mxN];
int fr[mxN];
int ans[mxN];
int gr[mxN];
signed main()
{
cin.tie(0);cout.tie(0);
ios_base::sync_with_stdio(0);
int n,k;
cin >>n>>k;
int num = 0;
for(int i = 0;i < n;i++){
cin >>a[i];
if(a[i] > k)
num++;
fr[a[i]]++;
}
for(int i = 0;i < n;i++){
if(a[i] > k){
int x = a[i] - k;
for(int j = 1;j * j <= x;j++){
if(x % j == 0){
if(j > k && j){
if(j == a[i])
ans[a[i]] += fr[j] - 1;
else
ans[a[i]] += fr[j];
}
if(x / j > k && x/ j != j){
if(x / j == a[i])
ans[a[i]] += fr[x / j] - 1;
else
ans[a[i]] += fr[x / j];
}
}
}
}else if(a[i] == k){
ans[a[i]] = num;
}
cout<<ans[a[i]]<<' ';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6356 KB |
Output is correct |
2 |
Incorrect |
8 ms |
3796 KB |
Output isn't correct |
3 |
Incorrect |
299 ms |
7728 KB |
Output isn't correct |
4 |
Incorrect |
864 ms |
10228 KB |
Output isn't correct |
5 |
Correct |
339 ms |
16992 KB |
Output is correct |
6 |
Incorrect |
982 ms |
19440 KB |
Output isn't correct |
7 |
Correct |
385 ms |
16928 KB |
Output is correct |
8 |
Correct |
394 ms |
17084 KB |
Output is correct |
9 |
Incorrect |
1125 ms |
19236 KB |
Output isn't correct |
10 |
Incorrect |
1134 ms |
19188 KB |
Output isn't correct |