답안 #199505

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

int n, k;
int a[N];

int q[N];
int qq[N];

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 < N; ++i)
    {
        if (i <= k)
            continue;
        for (int j = 0; j < N; 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 Runtime error 6 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 6 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 5 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)