Submission #308045

#TimeUsernameProblemLanguageResultExecution timeMemory
308045ErdosSzekeresSpiderman (COCI20_spiderman)C++14
70 / 70
244 ms16752 KiB
#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 timeMemoryGrader output
Fetching results...