文章

34

粉丝

9

获赞

5

访问

8.8k

头像
利润提成 题解:
P1040 北京大学机试题
发布于2024年6月29日 19:15
阅读数 271

#include <iostream>
using namespace std;

double calculate_bonus(double profit) {
    double bonus = 0;

    if (profit <= 100000) {
        bonus = profit * 0.1;
    } else if (profit <= 200000) {
        bonus = 100000 * 0.1 + (profit - 100000) * 0.075;
    } else if (profit <= 400000) {
        bonus = 100000 * 0.1 + 100000 * 0.075 + (profit - 200000) * 0.05;
    } else if (profit <= 600000) {
        bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (profit - 400000) * 0.03;
    } else if (profit <= 1000000) {
        bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + (profit - 600000) * 0.015;
    } else {
        bonus = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + 400000 * 0.015 + (profit - 1000000) * 0.01;
    }

    return bonus;
}

int main() {
    double profit;
    
    cin >> profit;

    double bonus = calculate_bonus(profit);
    cout<< bonus << endl;

...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发