답안 #344463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344463 2021-01-05T21:19:39 Z limabeans Spiderman (COCI20_spiderman) C++17
56 / 70
104 ms 12256 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;



int n, k;
int freq[maxn];
int ans[maxn];

vector<int> a;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>k;
    a.resize(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
	freq[a[i]]++;
    }


    // hi->hj if hi%hj=k
    /// hi = hj*x + k, hj>k

    for (int hj=k+1; hj<maxn; hj++) {
	for (int x=0; hj*x+k<maxn; x++) {
	    int hi = hj*x+k;
	    ans[hi] += freq[hj];
	}
    }


    for (int x: a) {
	cout<<ans[x]<<" ";
    }
    cout<<endl;    
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 6636 KB Output is correct
2 Correct 23 ms 5740 KB Output is correct
3 Correct 46 ms 8044 KB Output is correct
4 Correct 83 ms 10732 KB Output is correct
5 Incorrect 47 ms 9452 KB Output isn't correct
6 Incorrect 90 ms 12140 KB Output isn't correct
7 Correct 42 ms 9452 KB Output is correct
8 Correct 44 ms 9452 KB Output is correct
9 Correct 104 ms 12256 KB Output is correct
10 Correct 103 ms 12188 KB Output is correct