1.超时
2.你每次减的时候可能会变成负数
by huangxinyou @ 2024-01-22 10:56:37
这判断就有问题
c++的代码
```cpp
#include<bits/stdc++.h>
using namespace std;
long long a,c,p,q,r,x;
int main()
{
cin>>a>>c>>p>>q>>r>>x;
while(x!=0)
{
if(a<c)
{
x-=p;
a++;
}
if(a==c)
{
x-=q;
break;
}
}
cout<<x/r;
return 0;
}
```
by songthwell @ 2024-05-09 21:19:25
@[songthwell](/user/1010573)
是这个
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, c, p, q, r, x, cnt = 0;
cin >> a >> c >> p >> q >> r >> x;
if (a < c) {
if (x < p * (c - a)) {
cout << a + (x / p) << endl;
return 0;
}
if (x - p * (c - a) < q) {
cout << c;
return 0;
} else {
cout << c + (x - p * (c - a) - q) / r << endl;
}
}
if (a == c) {
if (x < q) {
cout << c;
} else {
cout << c + (x - q) / r;
}
}
if (a > c) {
cout << a + x / r;
}
return 0;
}
```
c++
by songthwell @ 2024-05-09 21:21:41