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