简单题,要注意可能做出0、1、2题,枚举所有情况即可;
# include <cstdio> int a, b, x, da, db, t; int i, j; void solve(void) { if (!x || (a>=x && (a-x)%da==0 && (a-x)/da<=t-1) || (b>=x &&(b-x)%db==0&&(b-x)/db<=t-1)) { printf("YES\n"); return ; } for (i = t-1; i >= 0; --i) for (j = t-1; j >= 0; --j) { if(a+b-x == i*da+j*db) {printf("YES\n"); return;} } printf("NO\n"); } int main() { while (~scanf("%d%d%d%d%d%d", &x, &t, &a, &b, &da, &db)) { solve(); } return 0; }