제출 #1370472

#제출 시각아이디문제언어결과실행 시간메모리
1370472FaresSTHSpiderman (COCI20_spiderman)C++20
70 / 70
46 ms10128 KiB
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
#define S second
#define F first
int f[1000001],res[1000001];
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        f[a[i]]++;
    }
    if(k==0){
        for(int i=k;i<=1000000;i++){
            if(!f[i])continue;
            for(int j=k;j<=1000000;j+=i)res[j]+=f[i]-(i==j);
        }
    }
    else{

    for(int i=k+1;i<=1000000;i++){
        if(!f[i])continue;
        for(int j=k;j<=1000000;j+=i)res[j]+=f[i];
    }
    }
    for(int i=0;i<n;i++)cout<<res[a[i]]<<' ';
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…