题解:P5709 【深基2.习6】Apples Prologue / 苹果和虫子
Dream_Stars · · 题解
犇犇里听说这道题可以写题解。
题目大意:
一共有
算法分析:
我们可以考虑
代码展示:
# include <bits/stdc++.h>
# define ll long long
# define int long long
# define rint register int
long long read(){long long s = 0 , w = 0; char c = getchar(); while(!isdigit(c)) w |= (c == '-') , c = getchar(); while(isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48) , c = getchar(); return w ? -s : s;}
void write(long long x){if(x < 0) putchar('-') , x = ~ (x - 1); if(x > 9) write(x / 10); putchar(x % 10 | 48);}
void writesp(long long x){write(x) , putchar(' '); }
void writeln(long long x){write(x) , putchar('\n');}
using namespace std;
long long m,t,s;
signed main() {
m = read(),
t = read(),
s = read();//输入数据。
if(t == 0) {//特判 t = 0 。
write(0);
return 0;
}
if(s % t == 0) write(max(m - s / t , (ll)0));
else write(max(m - s / t - 1 , (ll)0));//按是否可以整除输出答案。
return 0;
}