Documentation
¶
Index ¶
- func BigMulti(a, b string) string
- func ExGcd(a, n int) int
- func Gcd(a, b int) int
- func IntSliceEqualBce(a, b []int) bool
- func Lcm(a, b int) int
- func Max(nums ...int) int
- func Min(nums ...int) int
- func Power(a, b int) int
- func Reverse(s string) string
- func ReverseX(s string) string
- func ReverseXa(s string) string
- func StringSliceEqual(a, b []string) bool
- func StringSliceEqualBce(a, b []string) bool
- func StringSliceReflectEqual(a, b []string) bool
- func SumSlice(res []int) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Gcd ¶
Gcd 欧几里德算法 欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。其计算原理依赖于下面的定理:
定理:gcd(a,b) = gcd(b,a mod b)
证明:a可以表示成a = kb + r,则r = a mod b 假设d是a,b的一个公约数,则有 d|a, d|b,而r = a - kb,因此d|r 因此d是(b,a mod b)的公约数
假设d 是(b,a mod b)的公约数,则 d | b , d |r ,但是a = kb +r 因此d也是(a,b)的公约数
因此(a,b)和(b,a mod b)的公约数是一样的,其最大公约数也必然相等,得证
func IntSliceEqualBce ¶
func StringSliceEqual ¶
func StringSliceEqualBce ¶
func StringSliceReflectEqual ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.