| 利潤區間 (萬元) | 提成率 | 備註 |
|---|---|---|
| ≤ 10 | 10% | |
| 10 - 20 | 7.5% | 超過 10 萬部分 |
| 20 - 40 | 5% | 超過 20 萬部分 |
| 40 - 60 | 3% | 超過 40 萬部分 |
| 60 - 100 | 1.5% | 超過 60 萬部分 |
| > 100 | 1% | 超過 100 萬部分 |
預先計算各門檻累積獎金:
bonus1 = 100000 * 0.10; // 10000
bonus2 = bonus1 + 100000 * 0.075; // 17500
bonus4 = bonus2 + 200000 * 0.05; // 27500
bonus6 = bonus4 + 200000 * 0.03; // 33500
bonus10 = bonus6 + 400000 * 0.015; // 39500
#include <stdio.h>
int main(void) {
long profit;
int bonus;
scanf("%ld", &profit);
if (profit <= 100000)
bonus = profit * 0.10;
else if (profit <= 200000)
bonus = 10000 + (profit - 100000) * 0.075;
else if (profit <= 400000)
bonus = 17500 + (profit - 200000) * 0.05;
else if (profit <= 600000)
bonus = 27500 + (profit - 400000) * 0.03;
else if (profit <= 1000000)
bonus = 33500 + (profit - 600000) * 0.015;
else
bonus = 39500 + (profit - 1000000) * 0.01;
printf("Bonus = %d\n", bonus);
return 0;
}
階梯式累積計算避免重複乘法,邏輯清晰易維護。