编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#22193 #1119. Rhodoks的2-sum问题 Compile Error 0 0 ms 0 K C++ / 548 B paul0917 2020-02-11 22:47:12
显示原始代码
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    long long n, K;
    int u = 0;
    scanf("%lld %lld", &n, &K);
    int p[500000];
    for (int i = 0; i < n; i++) scanf("%d", p[i]);
    int q[500000][500000];
    for (int j = 0; j < n - 1; j++) {
        for (int i = j; i < n; ++i) {
            q[j][i] = p[j] + p[i];
        }
    }
    for (int j = 0; j < strlen(p); j++) {
        for (int i = 0; i < strlen(p); i++) {
            if (q[j][i] == K) {
                u++;
                break;
            }
        }
    }
    if (u != 0)
        printf("Yes");
    else
        printf("No");
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:11:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
  for (int i = 0; i < n; i++)scanf("%d", p[i]);
                                   ^~~~  ~~~~
/sandbox/1/a.cpp:12:22: error: size of array 'q' is too large
  int q[500000][500000];
                      ^
/sandbox/1/a.cpp:17:4: error: 'q' was not declared in this scope
    q[j][i] = p[j] + p[i];
    ^
/sandbox/1/a.cpp:20:29: error: cannot convert 'int*' to 'const char*'
  for (int j = 0; j < strlen(p) ; j++)
                             ^
In file included from /sandbox/1/a.cpp:2:
/usr/include/string.h:384:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
 extern size_t strlen (const char *__s)
                       ~~~~~~~~~~~~^~~
/sandbox/1/a.cpp:22:30: error: cannot convert 'int*' to 'const char*'
   for (int i = 0; i < strlen(p); i++)
                              ^
In file included from /sandbox/1/a.cpp:2:
/usr/include/string.h:384:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
 extern size_t strlen (const char *__s)
                       ~~~~~~~~~~~~^~~
/sandbox/1/a.cpp:24:8: error: 'q' was not declared in this scope
    if (q[j][i]==K)
        ^
/sandbox/1/a.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld", &n, &K);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:11:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i < n; i++)scanf("%d", p[i]);
                             ~~~~~^~~~~~~~~~~~