# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308045 | ErdosSzekeres | Spiderman (COCI20_spiderman) | C++14 | 244 ms | 16752 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long
#define pii pair<int,int>
#define pll pair<ll, ll>
const int MAXH=1e6+7;
int a[MAXH], ans[MAXH], freq[MAXH];
vector<int> v;
set<int> S;
int main(){
fastio;
int n,k; cin>>n>>k;
for(int i=0; i<n; i++){
cin >> a[i];
if(S.find(a[i])==S.end()){
v.push_back(a[i]);
}
freq[a[i]]++;
S.insert(a[i]);
}
for(int i=0; i<(int)v.size(); i++){//mark all numbers congruent to k mod v[i]
if(k >= v[i])continue;
for(int j=k; j < MAXH; j+=v[i]){
int aux = (v[i]==j) ? -1 : 0;
ans[j] += freq[v[i]] + aux;
}
}
for(int i=0; i<n; i++){
if(i>0)cout<<" ";
cout << ans[a[i]];
}
cout<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |