Run ID:7349

提交时间:2025-04-19 18:29:16

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int n,x,y,q; cin>>n>>x>>y; if(y%x!=0){ q=n-y/x-1; } else{ q=n-y/x; } if(q<0){ q=0; } cout<<q; return 0; } /* 假设有n个苹果,n=10,虫子每个x小时吃掉1个苹果,假设x=2.那么经过y小时,假设y=7 那么y/x=7/2=3,还有1个小时,这个小时虫子正在吃第4个苹果,那么剩下苹果n-3-1 (这个1有没有,取决于吃完前面的苹果还有没有多余的时间) 公式: 剩下的苹果数量=n-y/x-1(取决于是否开始吃下一个苹果) 还要注意苹果最多只可能剩下0个,不会出现负数的情况 ------Input------ 290 4 8 ------Answer----- 288 ------Your output----- 287 */