Problems > Divide and conquer?

Problem Statement

Today we will be dealing with very long numbers (up to 1000 digits), and the question is if those numbers are divisible by a list of given numbers:

The input is composed of three rows:
The first contains the number N, which is the number of numbers we would like to check divisibility by.
This number N will be smaller than 10.

The second row contains a list of N numbers which are the numbers we want to check divisibility for.
The third (and long) row will contain a number X with up to 1000 digits.

 

Those numbers may belong to several groups, and you may get partial scoring.

First group: The numbers 2,5 and 10

Next group: 4,25 and 100

Next group: 3 and 9

Next group: 11

Next group: 33 and 99

Next group: 7

Next group: 13, 31 and 101

Last group: Any multiplication of numbers from the former groups given that there are no more than 2 3's or one 11 in the list of divisors.

 

The output should contain a single test like which has the word “yes” for each of the N number that is a divisor of X and “no” for each such number that is not a divisor, those words should be separated by space.
The output will contain N words, by the same order that the numbers appeared on the second line of input.

 

Sample input #1

3
3 9 5
123456

Sample output #1

yes no no

Sample input #2

2
7 2
78

Sample output #2

no yes
You must be logged in to submit