Hi, my approach to the problem is to just check whether the total money available is divisible by each priced item in the array or not. If it is then I increment the counter otherwise not. At last if counter == k, then yes shopkeeper is right otherwise not. Thank you
MY CODE:
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
lli n;
cin >> n;
lli arr[n];
for(lli i = 0; i < n; i++) {
cin >> arr[i];
}
lli q;
cin >> q;
while(qβ) {
lli A, k, possible = 0;
cin >> A >> k;
for(lli i = 0; i < n; i++) {
if(A % arr[i] == 0) {
possible++;
}
}
(possible == k) ? cout << βYesβ : cout << βNoβ;
cout << endl;
}
return 0;
}