#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
using namespace std;
void solve(){
int n, k; cin >> n >> k;
int arr[n+1];
map<int, int> num;
map<int, int> ans;
int maxi=0;
for(int i=1; i<=n; i++){
cin >> arr[i];
num[arr[i]]++;
if(arr[i]>maxi) maxi=arr[i];
}
for(auto p:num){
if(k%p.st==0) continue;
for(int i=p.st+k; i<=maxi; i+=p.st){
ans[i]+=p.nd;
}
}
if(num[k]>0){
for(int i=k+1; i<=maxi; i++){
if(num[i]>0) ans[k]+=num[i];
}
}
for(int i=1; i<=n; i++) cout << ans[arr[i]] << " ";
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1610 ms |
110884 KB |
Output isn't correct |
2 |
Incorrect |
1580 ms |
116640 KB |
Output isn't correct |
3 |
Execution timed out |
2061 ms |
96592 KB |
Time limit exceeded |
4 |
Incorrect |
1735 ms |
116088 KB |
Output isn't correct |
5 |
Incorrect |
71 ms |
13904 KB |
Output isn't correct |
6 |
Incorrect |
157 ms |
14596 KB |
Output isn't correct |
7 |
Execution timed out |
2073 ms |
57264 KB |
Time limit exceeded |
8 |
Execution timed out |
2104 ms |
57672 KB |
Time limit exceeded |
9 |
Execution timed out |
2073 ms |
62760 KB |
Time limit exceeded |
10 |
Execution timed out |
2032 ms |
63960 KB |
Time limit exceeded |