#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 1000000007
//#define N 1000005
//#define big 1000000000000000007
int main(){
lalala;
int n,k;cin>>n>>k;
int cnt=0;
int arr[n];
map<int,int> mp;
for(int i=0;i<n;i++){
cin>>arr[i];
mp[arr[i]]++;
if(arr[i]>k)cnt++;
}
for(int i=0;i<n;i++){
if(arr[i]<k){cout<<"0 ";continue;}
if(arr[i]==k){cout<<cnt<<" ";continue;}
int uwu=arr[i]-k, cev=0;
//cout<<arr[i]<<" "<<uwu<<endl;
for(int j=1;j<=sqrt(arr[i]);j++){
if(uwu%j)continue;
//cout<<cev<<" "<<j<<" "<<uwu/j<<" "<<mp[j]<<" "<<mp[uwu/j]<<endl;
if(arr[i]%j==k){
cev+=mp[j];
}
if(j*j!=uwu && arr[i]%(uwu/j)==k)cev+=mp[uwu/j];
}cout<<cev<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
724 KB |
Output is correct |
2 |
Correct |
10 ms |
548 KB |
Output is correct |
3 |
Correct |
387 ms |
1504 KB |
Output is correct |
4 |
Correct |
1076 ms |
2976 KB |
Output is correct |
5 |
Incorrect |
653 ms |
8220 KB |
Output isn't correct |
6 |
Incorrect |
1922 ms |
9152 KB |
Output isn't correct |
7 |
Correct |
793 ms |
12816 KB |
Output is correct |
8 |
Correct |
737 ms |
12672 KB |
Output is correct |
9 |
Execution timed out |
2043 ms |
13924 KB |
Time limit exceeded |
10 |
Execution timed out |
2079 ms |
13984 KB |
Time limit exceeded |