Simple Division Solution

Simple Division

Given an array A of N integers and two integers X and Y, find the

number of integers in the array that are both less than or equal

to X and divisible by Y.

 


Input

The first line contains three space separated integers:

N. X and Y.

 

The second line contains N space-separated integers A1. A2.

... AN denoting the array A.

Output

 

line containing the answer.

Constraints

. 1S N < 105

. 1S A1. A2. ... . AN S 109

 

. 15X, Y s 109

Example

Input

321

123

Output

2

 

Explanation

 

All integers of the array are divisible by Y = 1 but only A1 = 1 and A2 = 2 are less

than or equal to X = 2. Hence, the count for the number of integers that are less

than or equal to 2 and divisible by 1 is 2.

 

 

Sample input >                                                                             Sample output

3 2 1                                                                                                               2

1 2 3



Program:




#include <stdio.h>

int main() {

    int n, x, y, count = 0;

    scanf("%d%d%d", &n, &x, &y);

    int a[n];

    for (int i = 0; i < n; i++) {

        scanf("%d", &a[i]);

        if (a[i] <= x && a[i] % y == 0) {

            count++;
        }

    }
    printf("%d\n", count);

    return 0;
}





Post a Comment

0 Comments