답안 #199506

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199506 2020-02-01T17:13:58 Z SamAnd Spiderman (COCI20_spiderman) C++17
56 / 70
166 ms 12152 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 25 ms 6520 KB Output is correct
2 Correct 28 ms 5624 KB Output is correct
3 Correct 56 ms 7928 KB Output is correct
4 Correct 114 ms 10488 KB Output is correct
5 Incorrect 67 ms 9464 KB Output isn't correct
6 Incorrect 134 ms 12152 KB Output isn't correct
7 Correct 80 ms 9464 KB Output is correct
8 Correct 69 ms 9464 KB Output is correct
9 Correct 142 ms 12024 KB Output is correct
10 Correct 166 ms 12024 KB Output is correct