unsigned char mod(unsigned char x, unsigned char y)
{
unsigned int a = x;
unsigned int b = y;
b <<= 7;
for (int i = 0; i < 8; i++) {
if (a >= b) {
a -= b;
}
b >>= 1;
}
return (unsigned char)a;
}
dW5zaWduZWQgY2hhciBtb2QodW5zaWduZWQgY2hhciB4LCB1bnNpZ25lZCBjaGFyIHkpCnsKCXVuc2lnbmVkIGludCBhID0geDsKCXVuc2lnbmVkIGludCBiID0geTsKCWIgPDw9IDc7Cglmb3IgKGludCBpID0gMDsgaSA8IDg7IGkrKykgewoJCWlmIChhID49IGIpIHsKCQkJYSAtPSBiOwoJCX0KCWIgPj49IDE7Cgl9CglyZXR1cm4gKHVuc2lnbmVkIGNoYXIpYTsKfQ==