deno.land / x / masx200_leetcode_test@10.6.5 / super-pow / superPow_mod.ts

superPow_mod.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { multiply_Mod } from "./multiply_Mod.ts";import { pow_bigint_mod } from "./pow_bigint_mod.ts";
export function superPow_mod(a: number, b: number[], m: number): number { if (a === 1) return 1; if (b.length === 0) { return 1; } if (b.length === 1) { return Number(pow_bigint_mod(BigInt(a), BigInt(b[0]), BigInt(m))); } let result = 1n; for (const e of b) { result = multiply_Mod( pow_bigint_mod(BigInt(result), BigInt(10), BigInt(m)), pow_bigint_mod(BigInt(a), BigInt(e), BigInt(m)), BigInt(m), ); } return Number(result);}
masx200_leetcode_test
leetcode题解和一些测试工具
DocumentationDocumentation
GitHub Repositorymasx200/leetcode-test
GitHub Stars
4

Version Info

Tagged at
4 months ago