#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;
ll int cnt=0;
ll int arr[n];
map<ll 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;}
ll int uwu=arr[i]-k;
ll int 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<<" ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
852 KB |
Output is correct |
2 |
Correct |
9 ms |
612 KB |
Output is correct |
3 |
Correct |
377 ms |
2052 KB |
Output is correct |
4 |
Correct |
1117 ms |
4268 KB |
Output is correct |
5 |
Incorrect |
736 ms |
11084 KB |
Output isn't correct |
6 |
Execution timed out |
2052 ms |
12636 KB |
Time limit exceeded |
7 |
Correct |
848 ms |
16916 KB |
Output is correct |
8 |
Correct |
825 ms |
16992 KB |
Output is correct |
9 |
Execution timed out |
2079 ms |
19148 KB |
Time limit exceeded |
10 |
Execution timed out |
2047 ms |
18860 KB |
Time limit exceeded |