Problem
You are given integers. Find the count of numbers divisible by .
Input Format
The input begins with two positive integers , . The next lines contains one positive integer each denoted by .
Output Format
Output a single number denoting how many integers are divisible by .
Constraints
Sample 1:
Input
Output
7 3 1 51 966369 7 9 999996 11
4
Explanation:
The integers divisible by are and . Thus, there are
integers in total.
ANSWER:-
#include <iostream>
using namespace std;
int main()
{
int n , k , count=0;
cin>>n>>k;
int a[n];
for(int i = 0 ; i<n ; i++)
{
cin>>a[i];
}
for(int j=0 ; j<n ; j++)
{
if(a[j] % k == 0 )
{
count++;
}
}
cout<<count;
return 0;
}
Comments
Post a Comment