#CCBCHBA0000008. Số phần tử chia hết cho k (Count Multiples in a Stream)
Số phần tử chia hết cho k (Count Multiples in a Stream)
Count Multiples in a Stream
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n (possibly negative or zero) integers and positive integer k, count how many are divisible by k. Process values as they are read without storing an array.
Input
Integers n and k, followed by exactly n integers.
Output
One integer: the number of values satisfying x % k == 0.
Subtasks
- Subtask 1 (20%): , , .
- Subtask 2 (30%): , , .
- Subtask 3 (50%): , , .
Examples
Example 1
Input
5 3
3 6 -9 2 0
Output
4
Explanation
3, 6, -9 and 0 are divisible by 3; 2 is not.
Example 2
Input
1 1
-7
Output
1
Explanation
Every integer is divisible by 1.