답안 #199507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199507 2020-02-01T17:14:22 Z SamAnd Spiderman (COCI20_spiderman) C++17
70 / 70
130 ms 10232 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 300005, M = 1000006;

int n, k;
int a[N];

int q[M];
int qq[M];

int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        q[a[i]]++;
    }
    for (int i = 1; i < M; ++i)
    {
        if (i <= k)
            continue;
        for (int j = 0; j < M; j += i)
            qq[j] += q[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] - k < 0)
            printf("0 ");
        else
        {
            if (a[i] % a[i] == k)
                printf("%d ", qq[a[i] - k] - 1);
            else
                printf("%d ", qq[a[i] - k]);
        }
    }
    printf("\n");
    return 0;
}

Compilation message

spiderman.cpp: In function 'int main()':
spiderman.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~
spiderman.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 6520 KB Output is correct
2 Correct 28 ms 5624 KB Output is correct
3 Correct 51 ms 7288 KB Output is correct
4 Correct 105 ms 8672 KB Output is correct
5 Correct 60 ms 8712 KB Output is correct
6 Correct 130 ms 10232 KB Output is correct
7 Correct 57 ms 8696 KB Output is correct
8 Correct 56 ms 8824 KB Output is correct
9 Correct 110 ms 10104 KB Output is correct
10 Correct 123 ms 10104 KB Output is correct