Skyler & Marie's Shoplifting
As we all know, Skyler & Marie are the most annoying creatures to ever exist in Albuquerque.
They went shopping together one day. But, Marie is a shoplifter & steals items from stores.
She asks Skyler to help her steal a necklace that she really liked.
Skyler accepts to help her, but she encounters a problem while doing so.
"I thought I made myself very clear."
She has a two-sided long ribbon in which there is a binary string K. On the other side, there is a decimal prime number M.
In order to shoplift, she needs to find out if M divides the decimal equivalent of K
INPUT
- First line contains an integer T denoting the number of test cases. Then T test cases follows.
- The first line of each test case contains a binary string K.
The second line of each test case contains a prime number. M.
OUTPUT
- For each test case print "YES" if M divides K else print "NO".
CONSTRAINTS
- 1 ≤ T ≤ 20
- 1 ≤|K| ≤10^5
- M is a prime number.
- 2 ≤ M <10^{6}
Explanation
For the first case:
decimal equivalent of '100001' is 33. 33 is divisible by the given prime number(11), hence answer is YES.
Time Limit:
1.0 sec(s)
for each input file.
Memory Limit:
256 MB
Source Limit:
1024 KB
Marking Scheme:
Marks are awarded when all the testcases pass.
Allowed Languages:
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Visual Basic,
Kotlin