Run ID:117273

提交时间:2025-04-15 22:27:36

#include <iostream> int main() { int a, B; std::cout << "请输入每只鸡腿的价格 (元): "; std::cin >> a; std::cout << "请输入小A手中的钱数 (元): "; std::cin >> B; if (a <= 0 || B < 0) { std::cerr << "价格和钱数必须是非负数" << std::endl; return 1; } int totalLegs = B / a; // 计算小A可以购买的鸡腿数量 int freeLegs = totalLegs / 3; // 计算赠送的鸡腿数量 int totalEatenLegs = totalLegs + freeLegs; // 总共能吃到的鸡腿数量 std::cout << "小A能吃到的鸡腿总数: " << totalEatenLegs << std::endl; return 0; }