In @hippie’s solution, I’ll elaborate a bit on what @mrho888 said.
Lets assume A = p1^a1 * p2^a2 … * pk^ak and B = q1^b1 * q2^b2 … qm^bm
To solve the problem, we need to see whether the set {q1…qm} is a subset of {p1…pk}. Now consider A^x: clearly if there exists any x such that A^x is not divisible by B, we can say that there is some prime in B that is not there in A and the answer to the problem is “NO”. Also, we can see that B divides A^x if and only if B contains all the prime divisors of A. Now all that remains is to find a big enough x such that B divides A^x. Now the largest necessary “x” occurs when A = p, B = p^x. Since A,B <= 10^18, with p = 2, we get the largest neccesary x as ceil(log2(10^18)) which is around 60.