File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,13 @@ fn search(target: u64, v: &[NonZero<u64>]) -> bool {
77 [ ] => unsafe { unreachable_unchecked ( ) } ,
88 [ rest @ .., last] => {
99 let last = last. get ( ) ;
10- if last >= target || rest. is_empty ( ) {
11- return rest . is_empty ( ) && last == target ;
10+ if rest. is_empty ( ) {
11+ return target == last ;
1212 }
13+ if last > target {
14+ return false ;
15+ }
16+
1317 if target % last == 0 {
1418 if search ( target / last, rest) {
1519 return true ;
@@ -74,9 +78,13 @@ fn search_part2(target: u64, v: &[NonZero<u64>]) -> bool {
7478 [ ] => unsafe { unreachable_unchecked ( ) } ,
7579 [ rest @ .., last] => {
7680 let last = last. get ( ) ;
77- if last >= target || rest. is_empty ( ) {
78- return rest . is_empty ( ) && last == target ;
81+ if rest. is_empty ( ) {
82+ return target == last ;
7983 }
84+ if last > target {
85+ return false ;
86+ }
87+
8088 if target % last == 0 {
8189 if search_part2 ( target / last, rest) {
8290 return true ;
You can’t perform that action at this time.
0 commit comments