#include <stdio.h>
#include <stdint.h>
uint8_t is_circular_match(uint16_t reg, uint16_t target) {
//First Check by Left Rotation
for(int i = 0; i < 16; i++){
//Check the MSB Bit of the Target
uint16_t MSB = target & 0x8000;
target <<= 1;
target |= MSB>>15;
if(target & reg) return 1;
}
// Check by Right Rotation
for(int i = 0; i < 16; i++){
//Check the LSB Bit of the Target
uint16_t LSB = target & 0x1;
target >>= 1;
target |= LSB << 15;
if(target & reg) return 1;
}
return 0;
}
int main() {
uint16_t reg, target;
scanf("%hu %hu", ®, &target);
printf("%hhu", is_circular_match(reg, target));
return 0;
}
Input
45056 11
Expected Output
1