Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
2つの数値aとbが与えられ、bは形式2 kであり、kは不明です。ビット演算子を使用してa%bを計算する効率的な方法は何でしょうか。
a AND(b-1)== a%b(bが2 ^ kの場合)
ex. a = 11 (1011b), b = 4 (0100b) 11 / 4 = 2 R3 11 % 4 == 11 AND (4-1) 11 (1011b) AND 3 (0011b) == 3 (0011b)