#include #include #include void mix(long *n, long r) { *n = *n ^ r; } void prune(long *n) { *n = *n % 16777216; } int main() { FILE *file = fopen("22.in", "r"); if (!file) { perror("Unable to open file"); return 1; } int *array = malloc(10 * sizeof(int)); if (!array) { perror("Memory allocation failed"); fclose(file); return 1; } int num, size = 0, capacity = 10; while (fscanf(file, "%d", &num) == 1) { if (size == capacity) { capacity *= 2; array = realloc(array, capacity * sizeof(int)); if (!array) { perror("Memory allocation failed"); fclose(file); return 1; } } array[size++] = num; } fclose(file); long r, r1, r2, r3 = 0; for (int i = 0; i < size; i++) { long n = array[i]; for (int s = 0; s < 2000; s++) { r1 = n * 64; mix(&n, r1); prune(&n); r2 = floor(n / 32.0); mix(&n, r2); prune(&n); r3 = n * 2048; mix(&n, r3); prune(&n); } r += n; } printf("%li\n", r); free(array); return 0; }