Submission #794718

# Submission time Handle Problem Language Result Execution time Memory
794718 2023-07-26T19:55:58 Z rainboy Present (RMI21_present) C
8 / 100
1 ms 296 KB
#include <stdio.h>

#define N	1000000
#define A	8

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int good(int s) {
	int a, B;

	for (a = 1; a <= A; a++)
		for (B = a + 1; B <= A; B++)
			if ((s & 1 << a) != 0 && (s & 1 << B) != 0 && (s & 1 << gcd(a, B)) == 0)
				return 0;
	return 1;
}

int main() {
	static int ss[N];
	int t, s, n;

	scanf("%d", &t);
	n = 0;
	for (s = 0; s < 1 << A + 1 && n <= N; s += 2)
		if (good(s))
			ss[n++] = s;
	while (t--) {
		int i, a, cnt;

		scanf("%d", &i);
		cnt = 0;
		for (a = 1; a <= A; a++)
			if ((ss[i] & 1 << a) != 0)
				cnt++;
		printf("%d", cnt);
		for (a = 1; a <= A; a++)
			if ((ss[i] & 1 << a) != 0)
				printf(" %d", a);
		printf("\n");
	}
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:24:20: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   24 |  for (s = 0; s < 1 << A + 1 && n <= N; s += 2)
      |                    ^~
Main.c:22:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
Main.c:30:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d", &i);
      |   ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -