add new solutions

This commit is contained in:
Yiyang Kang 2026-03-01 13:45:00 +09:00
parent ee1868a10e
commit 2012261d3d
7 changed files with 205 additions and 0 deletions

View file

@ -0,0 +1,23 @@
package q799
func champagneTower(poured, query_row, query_glass int) float64 {
buf := [100]float64{float64(poured)}
for r := range query_row + 1 {
var spill float64 = 0
for c := range r + 1 {
if r == query_row && c == query_glass {
return max(buf[c], 1)
}
if buf[c] > 1 {
buf[c] = (buf[c] - 1) / 2
buf[c], spill = buf[c]+spill, buf[c]
} else {
buf[c], spill = spill, 0
}
}
}
return 0
}
var _ = champagneTower