-
Notifications
You must be signed in to change notification settings - Fork 661
/
Copy pathhack.go
78 lines (69 loc) · 1.47 KB
/
hack.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package copypasta
import (
"fmt"
"maps"
"math/bits"
"slices"
)
/*
我贡献的 LC hack 数据
https://github.com/LeetCode-Feedback/LeetCode-Feedback/issues?q=is%3Aissue+author%3AEndlessCheng+is%3Aclosed
hack 乘法溢出
https://leetcode.cn/problems/frog-position-after-t-seconds/solutions/2281408/dfs-ji-yi-ci-you-qu-de-hack-by-endlessch-jtsr/
用所有的偶数 hack,O(U^logU)
https://leetcode.cn/problems/maximum-total-reward-using-operations-i/solutions/2805422/0-1-bei-bao-by-endlesscheng-702p/comments/2435993
https://yukicoder.me/problems/no/2700
LC2556
https://leetcode.cn/circle/discuss/gXygF3/view/ftWmDG/
考虑这样一个结构
1 1 1
1 0 1
1 1 1
……
*/
// 没找到符合要求的数据
func hackLC3411() {
gcd := func(a, b int) int {
for a != 0 {
a, b = b%a, a
}
return b
}
lcm := func(a, b int) int { return a / gcd(a, b) * b }
n := 10
calc := func(sub int) (l, g int) {
l = 1
for _s := uint(sub); _s > 0; _s &= _s - 1 {
p := bits.TrailingZeros(_s) + 1
l = lcm(l, p)
g = gcd(g, p)
}
return
}
all := map[int]bool{}
for sub := 1; sub < 1<<n; sub++ {
l, g := calc(sub)
all[l*g] = true
}
fmt.Println(slices.Sorted(maps.Keys(all)))
ps := []int{2, 3, 5, 7}
const mod = 1 << 32
for k := 1; k <= 100000; k++ {
for x0 := range all {
x := x0 + k*mod
a := []int{}
for _, p := range ps {
e := 0
for x%p == 0 {
x /= p
e++
}
a = append(a, e)
}
if x > 1 {
continue
}
fmt.Println(x0, a)
}
}
}