Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Created May 15, 2018 11:53
Show Gist options
  • Save henrybear327/c4907950ae336457ee359fa6575ed990 to your computer and use it in GitHub Desktop.
Save henrybear327/c4907950ae336457ee359fa6575ed990 to your computer and use it in GitHub Desktop.
recursion_witchcraft
#include <bits/stdc++.h>
using namespace std;
int main()
{
int ncase;
scanf("%d", &ncase);
while (ncase--) {
int d, a, b, c, A, B, C;
scanf("%d %d %d %d %d %d %d", &d, &a, &b, &c, &A, &B, &C);
bool ok = false;
for (int i = 0; i <= a; i++)
for (int j = 0; j <= b; j++)
for (int k = 0; k <= c; k++)
if (d == i * A + j * B + k * C)
ok = true;
printf("%s\n", ok ? "yes" : "no");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment