Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/McNuggets-problem/Go/mcnuggets-problem.go
Normal file
24
Task/McNuggets-problem/Go/mcnuggets-problem.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func mcnugget(limit int) {
|
||||
sv := make([]bool, limit+1) // all false by default
|
||||
for s := 0; s <= limit; s += 6 {
|
||||
for n := s; n <= limit; n += 9 {
|
||||
for t := n; t <= limit; t += 20 {
|
||||
sv[t] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := limit; i >= 0; i-- {
|
||||
if !sv[i] {
|
||||
fmt.Println("Maximum non-McNuggets number is", i)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
mcnugget(100)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue