add new solutions
This commit is contained in:
parent
ca24d0a56a
commit
0c73608ce5
36 changed files with 791 additions and 0 deletions
16
solutions/17/q1716/solution.go
Normal file
16
solutions/17/q1716/solution.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package q1716
|
||||
|
||||
func totalMoney(n int) int {
|
||||
if n <= 7 {
|
||||
return (1 + n) * n / 2
|
||||
}
|
||||
base := 28
|
||||
|
||||
rem := n % 7
|
||||
fullWeeks := n / 7
|
||||
moneyFW := (base-7)*fullWeeks + 7*(1+fullWeeks)*fullWeeks/2
|
||||
moneyRem := (1+rem)*rem/2 + rem*fullWeeks
|
||||
return moneyFW + moneyRem
|
||||
}
|
||||
|
||||
var _ = totalMoney
|
||||
Loading…
Add table
Add a link
Reference in a new issue