Submission #644926

# Submission time Handle Problem Language Result Execution time Memory
644926 2022-09-25T14:25:59 Z 1zaid1 Spiderman (COCI20_spiderman) C++17
56 / 70
535 ms 20996 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n';

const int M = 2e6+5, MOD = 1e9+7;
int fr[M], ans[M];

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int&i:v) cin >> i;
    for (int i:v) fr[i]++;
    for (int&i:v) i -= k;

    for (int i:v) {
        if (i < 0) continue;
        if (ans[i]) continue;
        for (int x = 1; x*x <= i; x++) {
            if (i%x == 0) {
                if ((i+k)%x == k) ans[i] += fr[x];
                if (x*x != i) if ((i+k)%(i/x) == k) ans[i] += fr[i/x];
            }
        }
    }

    for (int i:v) ans[0] += i > 0;

    for (int i:v) {
        if (i >= 0) cout << ans[i] << ' ';
        else cout << 0 << ' ';
    } cout << endl;

    return 0;
}
/*
a%b = k
6 3
4 3 12 6 8 2
   0 1 2 3 4 5 6 7 8 9 10 11 12
fr:1 1 0 1 0 0 0 0 0 1 0  0  0
as:0 0 0 0 0 0 0 0 0 0 0  0  0
*/
# Verdict Execution time Memory Grader output
1 Correct 9 ms 6356 KB Output is correct
2 Correct 6 ms 3796 KB Output is correct
3 Correct 40 ms 8300 KB Output is correct
4 Correct 243 ms 11212 KB Output is correct
5 Incorrect 361 ms 17552 KB Output isn't correct
6 Incorrect 355 ms 20996 KB Output isn't correct
7 Correct 401 ms 17640 KB Output is correct
8 Correct 409 ms 17608 KB Output is correct
9 Correct 495 ms 20940 KB Output is correct
10 Correct 535 ms 20884 KB Output is correct