| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 76550 | sh25_zhangjiajia | 计算邮资 | C++ | 通过 | 0 MS | 244 KB | 922 | 2025-12-19 15:25:32 |
#include <iostream> using namespace std; int main() { int weight; char urgent; cin >> weight >> urgent; int postage = 8; // 基础邮费 if (weight > 1000) { int excess = weight - 1000; // 超重的克数 // 步骤1:算能装满几个500克 int fullBags = excess / 500; // 比如200/500=0,600/500=1 // 步骤2:算有没有剩下的 int left = excess % 500; // 比如200%500=200,600%500=100 // 步骤3:如果有剩下的,多算1份 if (left > 0) { fullBags = fullBags + 1; // 比如200克→0+1=1份,600克→1+1=2份 } // 总超重费用 = 份数 × 4元 postage = postage + fullBags * 4; } // 加急费用 if (urgent == 'y') { postage = postage + 5; } cout << postage << endl; return 0; }