답안 #844349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844349 2023-09-05T12:31:07 Z vjudge1 Spiderman (COCI20_spiderman) C++17
70 / 70
58 ms 19284 KB
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define endl "\n" 
#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


const int N = 1e6 + 5;

void solve()
{
  int n,k;
  cin >> n >> k;
  int ar[n+1];
  for(int i=1;i<=n;i++) cin >> ar[i];
  vector<int> freq(N,0);
  for(int i=1;i<=n;i++) freq[ar[i]]++;
  
  vector<int> ans(N,0);

  for(int i=k+1;i<N;i++)
    for(int j=0;j<N;j+=i)
      ans[j+k]+=freq[i];

  for(int i=1;i<=n;i++)
  {
    cout << ans[ar[i]] - (k==0) << " \n"[i==n];
  }
}

int32_t main(){

  cin.tie(0); ios::sync_with_stdio(0);
  
  int t=1;//cin >> t;
  while(t--) solve();

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 15960 KB Output is correct
2 Correct 19 ms 15960 KB Output is correct
3 Correct 30 ms 17240 KB Output is correct
4 Correct 54 ms 19284 KB Output is correct
5 Correct 39 ms 16976 KB Output is correct
6 Correct 58 ms 19228 KB Output is correct
7 Correct 27 ms 16988 KB Output is correct
8 Correct 29 ms 16976 KB Output is correct
9 Correct 58 ms 18988 KB Output is correct
10 Correct 56 ms 19028 KB Output is correct