Run ID:7284
提交时间: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; }