苹果和虫子

#include<stdio.h>

#include<math.h>

int main() {

int m = 0;//现在有M个

int t = 0;//吃一个苹果要花的时间

int s = 0;//已经过去了s分钟

scanf_s("%d %d %d", &m, &t, &s);

int result = 0;

if (t == 0) {//如果吃一个苹果要0分钟 说明没有苹果

printf("0");

}

else {//有苹果的情况

if (s % t == 0) {//现有苹果一直够 且整个整个的吃

if (m > s / t) {

result = s / t;

result = m - result;

printf("%d", result);

}

else {

printf("0");//当按照过去的时间算苹果 为负数 说明已经没有苹果了

}

}

else {

if (m > s / t+1) {//现有苹果一直够 没有整个整个的吃

result = s / t+1;

result = m - result;

printf("%d", result);

}

else {

printf("0");

}

}

}

return 0;

}

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值