Will you be my friend?
Practice
3.8 (512 votes)
Open
Approved
Easy
Problem
74% Success 5215 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Max feels lonely after shifting to a new locality, as he does not have any friend there. So his parents bought him a new number from the Integers SuperMarket! Every child in the locality has bought a number from the same market.

He takes the number to go play with other children in the locality. But to his surprise, there is a rule in the locality, two people A and B can only be considered friends if numbers with A and B are not Coprime, i.e they have a common factor other than 1.

You are given the number that Max bought and the numbers of other children in the locality. Can you find how many friends he can have?

Input:
First line contains an integer A, the number that Max has.
Second line contains N, the count of children in the locality.
Third line contains N space-separated integers, where Xi is the integer with the ith child.

Output:
Output the maximum number of friends that Max can make.

Constraints:
1 ≤ A ≤ 103
1 ≤ N ≤ 103
1 ≤ Xi ≤ 103

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
2 votes
Points:30
290 votes
Tags:
ReadyBit manipulationApprovedEasy-Medium
Points:20
12 votes
Tags:
Greatest common divisorAlgorithmsGCDMathNumber Theory