#include <stdio.h> #include <stdint.h> uint8_t is_circular_match(uint16_t reg, uint16_t target) { // Your code here uint16_t temp1 = reg,temp2 = reg; if(reg == target) { return 1; }else { for(int i = 1; i < sizeof(target) * 8; i++) { temp2 = ( temp1 >> 16-1 ) & 1; // 1101 . 0001 1011 0111 temp1 = temp1 << 1; // 1101 , 1010 0111 1110 : 1011 temp1 = temp1 | temp2; // 1011 if(temp1 == target) { return 1; } } } return 0; } 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