#include <stdbool.h> #include <stdint.h> #include <stdio.h> uint8_t is_circular_match(uint16_t reg, uint16_t target) { bool circular = false; int i = 0; while (i < 16 && !circular) { reg = (reg << 1) | (reg >> (16 - 1)); if (reg == target) { circular = true; } i += 1; } return circular; } int main() { uint16_t reg, target; scanf("%hu %hu", ®, &target); printf("%hhu", is_circular_match(reg, target)); return 0; }
Test Cases
Test Results
Input
45056 11
Expected Output
1