Enormous Input Test | CodeChef Solution

Today we will be solving Enormous Input Test CodeChef Solution in C++. So, without further ado let’s jump to the question.

enormous-input-test-codechef-solution-codebros

Problem

The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.

Input

The input begins with two positive integers n k (n, k<= 107). The next n lines of input contain one positive integer ti, not greater than 109, each.

Output

Write a single integer to output, denoting how many integers ti are divisible by k.

Example

Input

7 3
1
51
966369
7
9
999996
11

Output

4

Solution – Enormous Input Test CodeChef Solution (C++)

Python 3

#Solution provided by CodingBroz
N, K = map(int, input().split())
count = 0
while N > 0:
    a = int(input())
    if (a % K == 0):
        count += 1
    else:
        0
    N = N - 1
print(count)   

C++

// Note that this problem is for testing fast input-output.
// We can use scanf, printf in C langauge, which are quite fast in general :)
#include <bits/stdc++.h> 

using namespace std;

// Usually, you can use scanf/printf in C++.
// However, if you want to use cin/cout, it is usually slow.
// To make it faster. Use cin.tie(NULL) and set ios_base::sync_with_stdio(false)
// See the below code for details.

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// Read the input n, k
	int n, k;
	cin >> n >> k;

	// ans denotes number of integers n divisible by k
	int ans = 0;

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		
		if (t % k == 0) {
			ans++;
		}		
	}

	// Print the ans.
	cout << ans << "\n";	
		
	return 0;
}

Disclaimer: The above problem (Enormous Input Test) is generated by CodeChef but the solution is provided by CodingBroz.

Broz Who Code

CodingBroz

Leave a Comment

Your email address will not be published. Required fields are marked *