Download benchmarks/Algorithms/modular_mul/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 316 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/modular_mul/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/modular_mul/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/modular_mul/solution.c
316 Bytes
| int modular_mul(int a, int b, int modulus) | |
| { | |
| int res = 0; | |
| int flag = 1; | |
| if (b < 0) { | |
| b = -b; | |
| flag = -1; | |
| } | |
| while (b > 0) { | |
| if (b % 2 == 1) { | |
| res = (res + a) % modulus; | |
| } | |
| b = b / 2; | |
| a = (a + a) % modulus; | |
| } | |
| return res * flag; | |
| } | |