#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main(){
fast;
int n,k;
cin>>n>>k;
int arr[n],cnt=0;
map<int,int>mp;
for(int i=0;i<n;i++){
cin>>arr[i];
if(arr[i]>k)cnt++;
mp[arr[i]]++;
}
for(int i=0;i<n;i++){
if(arr[i]==k){
cout<<cnt<<" ";
continue;
}
int ans=0;
arr[i]-=k;
for(int j=1;j*j<=arr[i];j++){
if(arr[i]%j)continue;
if(j>k)ans+=mp[j];
if(arr[i]/j>k && j*j!=arr[i])ans+=mp[arr[i]/j];
}
cout<<ans-(k==0)<<" ";
}
cout<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
852 KB |
Output is correct |
2 |
Correct |
9 ms |
632 KB |
Output is correct |
3 |
Correct |
378 ms |
2124 KB |
Output is correct |
4 |
Correct |
1032 ms |
4280 KB |
Output is correct |
5 |
Correct |
699 ms |
11000 KB |
Output is correct |
6 |
Correct |
1873 ms |
12544 KB |
Output is correct |
7 |
Correct |
758 ms |
17160 KB |
Output is correct |
8 |
Correct |
788 ms |
17024 KB |
Output is correct |
9 |
Execution timed out |
2020 ms |
19100 KB |
Time limit exceeded |
10 |
Execution timed out |
2054 ms |
19004 KB |
Time limit exceeded |