Submission #16483

# Submission time Handle Problem Language Result Execution time Memory
16483 2015-08-26T11:20:10 Z who7117 로봇 심판의 님 게임 (kriii3_F) C++
Compilation error
0 ms 0 KB
#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

S.cpp:4:11: error: ‘::main’ must return ‘int’
 void main()
           ^
S.cpp: In function ‘int main()’:
S.cpp:43:12: error: name lookup of ‘y’ changed for ISO ‘for’ scoping [-fpermissive]
    bot = k[y] + 1;
            ^
S.cpp:43:12: note: (if you use ‘-fpermissive’ G++ will accept your code)
S.cpp: At global scope:
S.cpp:51:1: error: expected declaration before ‘}’ token
 }
 ^
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]);
                     ^