设 \(x\) 轮为负操作,\(y\) 轮为正操作,\(d\) 为需要修改的差值(正负同理,取正即可),那么可更改成的范围为 \(-x \times R +y*L \sim -x*L+y*R\),令上式为 \(M \sim N\),易得 M 为最小的可能值,N 为最大的可能值,可通过不断给 M 加 1,使 M 变成 N。
综上,枚举 \(x \in [0 \sim t]\),判断合法即可。
代码于此
//U602854 -std
#include<iostream>
#include<algorithm>
#include<cstdio>
#define int long long
using namespace std;
inline void read(int &x){int f=1; char ch=getchar(); x=0;while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+(ch-'0');ch=getchar();}x*=f;
}
inline void write(int x){if(x<0) putchar('-'),x=-x;if(x>=10) write(x/10);putchar(x%10+'0');
}
int T,x,y,t,L,R,d;
inline bool check(){for(int k=0;k<=t;k++)if(L*k-R*(t-k)<=d&&d<=R*k-L*(t-k)) return true;return false;
}
signed main(){read(T);while(T--){read(x); read(y); read(t); read(L); read(R);d=y-x;if(check()) puts("Succeed");else puts("Die");}return 0;
}