J.Little Sub and Apples

博客围绕计算苹果数量问题展开。Little Sub初始有n个苹果,在接下来t天里每天吃k个,若苹果数少于k则全吃。输入n、k、t三个整数,题解为输出max(0,n - t*k)。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

Little Sub loves eating apples and he has n apples initially.
In the following t days, Little Sub will eat k apples each day. If the number of apple is less than k, he will eat all apples instead.
Please calculate the number of apples after t days.

Input

In the fisrt line, it contains three integer n, k, t(0 ≤ n, k, t ≤ 2^31 − 1).

Output

Output the answer in one line.

Author
CHEN, Jingbang

题解:水题,max(0,n-t*k)输出即可.
#include <iostream>
//#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
    ll n,k,t;
    cin>>n>>k>>t;
    cout<<max(ll(0),n-k*t)<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}

转载于:https://www.cnblogs.com/-yjun/p/10549912.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值