# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471322 | HossamHero7 | Spiderman (COCI20_spiderman) | C++14 | 2092 ms | 10356 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;
typedef long long ll;
#define endl '\n'
void solve(){
int n,k;
cin>>n>>k;
vector <int> v(n);
for(auto &i:v) cin>>i;
if(k == 0){
map <int,int> mp;
for(auto i : v) mp[i] ++;
int cnt=0;
vector <int> ans(n);
for(auto i : v){
for(int j=1;j*j<=i;j++){
if(i == j){
ans[cnt] += mp[i]-1;
if(i == 1){
ans[cnt] += mp[i]-1;
}
else ans[cnt] += mp[1];
}
else {
if(i % j == 0){
ans[cnt] += mp[j];
if(j == (i/j)) continue;
if(i == (i/j)){
ans[cnt] += mp[i]-1;
}
else {
if(i % (i/j) == 0) ans[cnt] += mp[i/j];
}
}
}
}
cnt ++;
}
for(auto i : ans){
cout<<i<<" ";
}
cout<<endl;
}
else {
set <int> s;
map <int,int> mp;
for(auto i : v){
mp[i] ++;
s.insert(i);
}
map <int,int> ans;
for(auto i : s){
for(auto j : s){
if(i != j){
if(i%j == k) ans[i] += mp[j];
}
else {
if(i%j == k) ans[i] += mp[j]-1;
}
}
}
for(auto i : v) cout<<ans[i]<<" ";
cout<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
while(t--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |