#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define int long long
using namespace std;
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> p){ return os << p.first << " " << p.second; }
void solve(void){
int n,k, morethank=0;
cin >> n >> k;
vector<int> h(n), ans(n, 0);
for(auto &gh: h){
cin >> gh;
if(gh>k)
morethank++;
}
vector<int> bruh(1e6+7, 0);
for(int i=0; i<n; i++)
bruh[h[i]]++;
for(int i=0; i<n; i++){
int gh = h[i] - k;
if(gh == 0)
ans[i] = morethank;
for(int l=1; l*l<=gh; l++){
if(gh%l == 0){
if(l>k)
ans[i]+= bruh[l];
if(l*l != gh )
if( gh/l > k )
ans[i]+= bruh[gh/l];
}
}
if( k==0 && h[i]>0 )
ans[i]--;
}
for(auto ghh: ans)
cout << ghh << " ";
cout << "\n";
}
signed main(){
int t=1;
// cin >> t;
while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8280 KB |
Output is correct |
2 |
Correct |
7 ms |
8316 KB |
Output is correct |
3 |
Correct |
279 ms |
10096 KB |
Output is correct |
4 |
Correct |
818 ms |
13836 KB |
Output is correct |
5 |
Correct |
321 ms |
9824 KB |
Output is correct |
6 |
Correct |
934 ms |
13712 KB |
Output is correct |
7 |
Correct |
361 ms |
9820 KB |
Output is correct |
8 |
Correct |
362 ms |
9824 KB |
Output is correct |
9 |
Correct |
1070 ms |
13712 KB |
Output is correct |
10 |
Correct |
1066 ms |
13652 KB |
Output is correct |