Banner Home Page Web Contests Problems Ranklist Status Statistics

Number Puzzle

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 5   Accepted Submission(s) : 1
Problem Description

<!--
Problem text file for ZheJiang University Online Judge
Created by LiuYaoting
-->


Given a list of integers (A<sub>1</sub>, A<sub>2</sub>, ..., A<sub>n</sub>), and a positive integer M, please find the number of positive integers that are not greater than M and dividable by any integer from the given list.
</p>

<p><b>Input</b></p>

<p>
<p>
The input contains several test cases.
</p>
<p>
For each test case, there are two lines. The first line contains N (1 &lt;= N &lt;= 10) and M (1 &lt;= M &lt;= 200000000), and the second line contains A<sub>1</sub>, A<sub>2</sub>, ..., A<sub>n</sub>(1 &lt;= A<sub>i</sub> &lt;= 10, for i = 1, 2, ..., N).
</p>

<p><b>Output</b></p>

<p>
For each test case in the input, output the result in a single line.
</p>

<p><b>Sample Input</b></p>

<p>
3 2<br>
2 3 7<br>
3 6<br>
2 3 7<br>
<br>
</p>

<p><b>Sample Output</b></p>

<p>
1<br>
4<br>
</p>

 

Source
Zhejiang University Local Contest 2007
 

Statistic | Submit | Back