30分求助!!
查看原帖
30分求助!!
926722
AlexKun楼主2023/2/19 13:49
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int p(int x)
{
    if(x <= 1000)
    {
        return 8;
    }
    else
    {
        int f = ceil((x - 1000) / 500);
        return 8 + 4 * f;
    }
}

int main()
{
    int x;
    string jj;
    cin >> x >> jj;
    if(jj == "n")
    {
        cout << p(x);
    }
    else cout << p(x) + 5 << endl;
    return 0;
}

思路就是写1个分段函数(不包括判断是否加急),返回不加急的邮资,主函数特判加急情况。但是本蒟蒻改了两年半还是没AC。。。

2023/2/19 13:49
加载中...