ANSWER

王晨逸  •  18天前


#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;
}


评论: