Submission #16486

#TimeUsernameProblemLanguageResultExecution timeMemory
16486who7117로봇 심판의 님 게임 (kriii3_F)C++14
Compilation error
0 ms0 KiB
#include<stdio.h> #include<stdlib.h> void main() { int N, M, K; int *p, *q, *k; int bot = 0, top = 0, toggle = 0; // bot = 구슬 가장 적게 꺼낸 뒤 주머니 구슬의 수 // top = 이기기 위해 꺼내는 구슬의 수 // 1 <= N,M N+M <= 16 1 <= K <= 20 // N,M : 주머니를 검사하는 조건의 개수 // K : 처음 주머니의 개수 scanf("%d %d %d", &N, &M, &K); p = (int*)malloc(sizeof(int)*N); q = (int*)malloc(sizeof(int)*M); k = (int*)malloc(sizeof(int)*K); for (int i = 0; i < N; i++) scanf("%d", &p[i]); for (int i = 0; i < M; i++) scanf("%d", &q[i]); for (int i = 0; i < K; i++) scanf("%d", &k[i]); for (int y = 0; y < K; y++) { top = 0; bot = 0; for (k[y]--; k[y] > 0 && toggle == 0; k[y]--) { top++; for (int i = 0; (i < N) && (toggle == 0); i++) if (k[y] % p[i] == 0) toggle = 1; for (int i = 0; (i < M) && (toggle == 0); i++) if (k[y] % q[i] != 0) toggle = 1; } if (toggle == 1) { bot = k[y] + 1; toggle = 0; } if (bot == 0) printf("0 0\n"); else printf("%d %d\n", top, bot); } }

Compilation message (stderr)

S.cpp:4:11: error: ‘::main’ must return ‘int’
 void main()
           ^
S.cpp: In function ‘int main()’:
S.cpp:15:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &N, &M, &K);
                               ^
S.cpp:21:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &p[i]);
                     ^
S.cpp:23:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q[i]);
                     ^
S.cpp:25:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k[i]);
                     ^