Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
7284 | 侯宜辰 | 08打车费用 | C++ | Wrong Answer | 0 MS | 272 KB | 624 | 2025-04-12 14:16:17 |
#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { int distance; cin >> distance; double cost = 0.0; // 计算费用 if (distance <= 2) { cost = 6; } else if (distance <= 10) { cost = 6 + (distance - 2) * 1.8; } else { cost = 6 + 8 * 1.8 + (distance - 10) * 2.7; } // 判断输出格式 if (cost == floor(cost)) { cout << static_cast<int>(cost); // 整数输出 } else { cout << fixed << setprecision(1) << cost; // 一位小数 } return 0; }
------Input------
68
------Answer-----
177
------Your output-----
177.0