Skip to content

Commit

Permalink
Merge pull request #674 from isucon/adjust-chair-increase
Browse files Browse the repository at this point in the history
椅子の増え方を調整
  • Loading branch information
wtks authored Dec 6, 2024
2 parents 856ae18 + 0b52b1b commit 1f12720
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions bench/benchmarker/world/owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,20 @@ func (p *Owner) ValidateChairs(serverSide *GetOwnerChairsResponse) error {
return nil
}

const (
desiredChairNumFirstTerm = 15000
desiredChairNumCommonRatio = 1.02
)

var (
desiredChairNum50thTerm = desiredChairNumFirstTerm * math.Pow(desiredChairNumCommonRatio, 50-1)
desiredChairNum50Sum = int(desiredChairNumFirstTerm * (math.Pow(desiredChairNumCommonRatio, 50) - 1) / (desiredChairNumCommonRatio - 1))
)

func desiredChairNum(s int) int {
const (
a = 15000
r = 1.02
)
return int(math.Log((a-float64(s)*(1-r))/a) / math.Log(r))
if s >= desiredChairNum50Sum {
// 50個以降は必要売り上げが一定
return 50 + int(float64(s-desiredChairNum50Sum)/desiredChairNum50thTerm)
}
return int(math.Log((desiredChairNumFirstTerm-float64(s)*(1-desiredChairNumCommonRatio))/desiredChairNumFirstTerm) / math.Log(desiredChairNumCommonRatio))
}
2 changes: 1 addition & 1 deletion bench/benchmarker/world/owner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "testing"

func TestDesiredChairNum(t *testing.T) {
n := 0
for i := 0; i < 10000; i++ {
for i := 0; i < 30000; i++ {
num := desiredChairNum(i * 100)
if num > n {
n = num
Expand Down

0 comments on commit 1f12720

Please sign in to comment.