P5709没思路有没有大佬帮亿下

P5709 【深基2.习6】Apples Prologue / 苹果和虫子

题解是个好东西@[DISGUSTING114](/user/1068736)
by liu_le_chen @ 2023-08-31 10:28:40


你知道有个东西叫tj吗
by JiCanDuck @ 2023-08-31 10:28:40


@[DISGUSTING114](/user/1068736) 有个东西叫题解(温馨提醒:不要直接抄代码,而是借鉴思路,不然棕名两行泪)
by Acceptedit_ @ 2023-08-31 11:23:38


```cpp #include<iostream> using namespace std; int main(){ int n,x,y,z; cin>>n>>x>>y; if(y%x==0) z=n-y/x; else z=n-(y/x+1); if(z<0) cout<<0; else cout<<z; return 0; } ``` 给你看下,不过这个代码有一个测试点RE
by Codingyyt @ 2023-08-31 11:23:48


@[DISGUSTING114](/user/1068736) 首先看过去时间里能不能正好吃完整数个苹果,可以就直接减,不可以就再减一个。 然后判断剩下是否为正负数就OK了
by Codingyyt @ 2023-08-31 11:28:46


正数直接输出,0和负数输0
by Codingyyt @ 2023-08-31 11:29:41


至于RE,自己加特判。题解应该好一些
by Codingyyt @ 2023-08-31 11:32:23


@[Codingyyt](/user/1075561) 谢谢
by JerryLOL6 @ 2023-08-31 18:23:29


``` #include<bits/stdc++.h> using namespace std; int m,t,s; int main() { cin>>m>>t>>s; if(t==0) { cout<<0<<endl; return 0; } if(s%t==0) cout<<max(m-s/t,0)<<endl; else cout<<max(m-s/t-1,0)<<endl; return 0; } ```
by zhangbochen @ 2023-10-21 16:38:51


|