// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define int long long int
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 1e6 + 5;
inline void solve(){
int n, k;
cin >> n >> k;
pair<int, int> a[n];
rep(i, 0, n) cin >> a[i].ff;
rep(i, 0, n) a[i].ss = i;
int cnt[N];
rep(i, 0, N) cnt[i] = 0;
int ans[n];
sort(a, a+n);
rev(a, a+n);
rep(i, 0, n){
cnt[a[i].ff]++;
}
rep(i, 0, n){
ans[a[i].ss] = 0;
if(a[i].ff == k){
ans[a[i].ss] = i;
}
a[i].ff -= k;
vector<int> v;
for(int j = 1; j <= sqrt(a[i].ff); j++){
if(a[i].ff % j == 0){
v.pb(j);
if(j != (a[i].ff/j)) v.pb(a[i].ff / j);
}
}
for(int j : v) {
if(j <= k) continue;
ans[a[i].ss] += cnt[j];
}
}
rep(i, 0, n) cout << ans[i] << " ";
cout << endl;
}
int32_t main(){
fast_io
int t;
t = 1;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
8284 KB |
Output is correct |
2 |
Correct |
10 ms |
8284 KB |
Output is correct |
3 |
Incorrect |
293 ms |
10860 KB |
Output isn't correct |
4 |
Correct |
854 ms |
16076 KB |
Output is correct |
5 |
Incorrect |
340 ms |
11008 KB |
Output isn't correct |
6 |
Incorrect |
990 ms |
16212 KB |
Output isn't correct |
7 |
Correct |
384 ms |
10832 KB |
Output is correct |
8 |
Correct |
385 ms |
10836 KB |
Output is correct |
9 |
Correct |
1112 ms |
16208 KB |
Output is correct |
10 |
Correct |
1109 ms |
15816 KB |
Output is correct |