src/math/mul_mod/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../safe_mod/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | 3680995596 | CEXP i64 mul_mod_s(i64 a, i64 b, u64 mod) NE { | |
| 8 |
2/2✓ Branch 4 taken 3680995481 times.
✓ Branch 5 taken 115 times.
|
3680995596 | if (std::bit_width((u64)abs(a)) + std::bit_width((u64)abs(b)) < 64) return safe_mod(a * b % (i64)mod, mod); |
| 9 | 115 | return safe_mod((i64)((i128)a * b % mod), mod); | |
| 10 | } | ||
| 11 | 24012336890 | CEXP u64 mul_mod_u(u64 a, u64 b, u64 mod) NE { | |
| 12 |
2/2✓ Branch 2 taken 18036376256 times.
✓ Branch 3 taken 5975960634 times.
|
24012336890 | if (std::bit_width(a) + std::bit_width(b) <= 64) return a * b % mod; |
| 13 | 5975960634 | return (u64)((u128)a * b % mod); | |
| 14 | } | ||
| 15 | |||
| 16 | } // namespace tifa_libs | ||
| 17 |