Description of enormous input test problem

enormous-input-output-problem-solving-by-c-solution-to-enormous-input-output

In this enormous input test problem we have to test how many given numbers are divisible by a specific number. The user will give two integer first. The first number is the number of integers which we have to check. Second integer is that specific integer by which we have to check the divisibility of the upcoming integers.

After checking all the integers we have to print how many integers are divisible by that number.

We have taken this enormous input test problem from CodeChef for practice and learning purpose. We will discuss about the problem and its solution in this guide.

Solution to enormous input test problem

Imagine the user gives two number which is 7 and 3. Now, the user will give more 7 integers and we have to check how many integers among them are divisible by 3.

Consider he has given the more 7 integers which are as follows;

3

55

966

9

2

999

10

Now, we will check which integers are divisible by 3. Here, 3,  966,  9 and 999 are divisible by 3. As total 4 integers are divisible by 3 and so we will print the output 4.

Let’s go the the source code of enormous input test bellow;

// enormous input test problem solving in C++

#include<iostream>
using namespace std;

int main(){
    int i, j, counter = 0;
    cin >> i >> j;

    for(int x = 0; x < i; x++){
        int y;
        cin >> y;

        if(y % j == 0){
            counter++;
        }
    }

    cout << counter << endl;
    
    return 0;
}

Compile and run this enormous input test program to get the following output.

7 3
1
51
966369
7
9
999996
11
4

In the output console first line contains the two number. First is the number of upcoming integers which we have to test. Second one is the number by which we will divide the upcoming integers. Then 7 line and each line has one integers. At the last line we have printed our output which is 4. Because only 4 integers are divisible by 3 here.

Previous pageSum of digits

Next pageJump to C++ Projects section