Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
137450 练明一 07苹果和虫子 C++ Accepted 1 MS 272 KB 746 2025-11-17 17:14:27

Tests(10/10):


Code:

#include <iostream> using namespace std; int main() { int n, x, y; // 读取输入的三个正整数 cin >> n >> x >> y; // 计算被吃掉的苹果数量 int eaten_apples = 0; // 如果y能被x整除,说明刚好被整数个虫子吃完 if (y % x == 0) { eaten_apples = y / x; } else { // 否则需要向上取整,因为即使吃不满也要算一个完整的苹果 eaten_apples = y / x + 1; } // 计算剩余的苹果数量,确保不会出现负数 int remaining_apples = n - eaten_apples; if (remaining_apples < 0) { remaining_apples = 0; } // 输出结果 cout << remaining_apples << endl; return 0; }