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