Skip to content

Instantly share code, notes, and snippets.

@spdskatr
Created April 14, 2019 13:39
Show Gist options
  • Save spdskatr/24029b2559815937f0303ff8365b149a to your computer and use it in GitHub Desktop.
Save spdskatr/24029b2559815937f0303ff8365b149a to your computer and use it in GitHub Desktop.
GCJ 2019 Round 1A Problem 2 "Golf Gophers" solution with N = 6
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int T, N, M, sieve[1000005];
int q[6] = { 17, 9, 7, 11, 13, 16 };
int res[6];
void do_q(int j) {
for (int i = 0; i < 18; i++) {
if (i == 0) printf("%d", q[j]);
else printf(" %d", q[j]);
} printf("\n"); fflush(stdout);
for (int i = 0; i < 18; i++) {
int a; scanf("%d", &a);
res[j] += a;
}
res[j] %= q[j];
}
int main() {
scanf("%d%d%d", &T, &N, &M);
for (int t = 1; t <= T; t++) {
memset(res, 0, sizeof(res));
for (int i = 0; i < 6; i++) {
do_q(i);
}
// Regular for loop brute force because i cbs implementing CRT
int found = 0;
for (int i = res[0]; !found && i <= M; i += q[0]) {
int cooked = 0;
for (int j = 1; j < 6; j++) if (i % q[j] != res[j]) { cooked = 1; break; }
if (!cooked) {
printf("%d\n", i); fflush(stdout);
found = 1;
}
}
int verdict;
scanf("%d", &verdict);
if (verdict == -1) return 0;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment