Skip to main content

Enormous Input Test | INTEST

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

Popular posts from this blog

Id and Ship | FLOW010

Problem Write a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below. Class ID Ship Class B or b BattleShip C or c Cruiser D or d Destroyer F or f Frigate Input Format The first line contains an integer  T , the total number of testcases. Then  T  lines follow, each line contains a character. Output Format For each test case, display the Ship Class depending on ID, in a new line. Constraints 1  ≤   T   ≤  1000 Sample 1: Input Output 3 B c D BattleShip Cruiser  Destroyer   Solution: #include <iostream> using namespace std; int main() { // your code goes here int t; char ch; cin>>t; while(t--) { cin>>ch; if(ch=='B' || ch=='b') cout<<"BattleShip"<<endl; if(ch=='C' || ch=='c') cout<<"Cruiser"<<endl; if(ch=='D' || ch=='d') cout<<"Destroyer"<...

Sum of Digits | FLOW006

  Problem You're given an integer  N . Write a program to calculate the sum of all the digits of  N . Input Format The first line contains an integer  T , the total number of testcases. Then follow  T  lines, each line contains an integer  N . Output Format For each test case, calculate the sum of digits of  N , and display it in a new line. Constraints 1 ≤ � ≤ 1000 1 ≤ T ≤ 1000 1 ≤ � ≤ 1000000 1 ≤ N ≤ 1000000 Sample 1: Input Output 3 12345 31203 2123 15 9 8 Solution: #include <bits/stdc++.h> using namespace std; int main() {     int t;     cin>>t;     while(t--)     {         int n;         cin>>n;         int sum = 0;         while(n!=0)         {             int r = n%10;             sum+= r;           ...

Valid Triangles | FLOW013

  Problem Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees. Input Format The first line contains an integer  T , the total number of testcases. Then  T  lines follow, each line contains three angles  A ,  B  and  C , of the triangle separated by space. Output Format For each test case, display 'YES' if the triangle is valid, and 'NO', if it is not, in a new line. Constraints 1  ≤   T   ≤  1000 1  ≤   A,B,C   ≤  180 Sample 1: Input Output 3 40 40 100 45 45 90 180 1 1 YES YES NO Solution: #include <iostream> using namespace std; int main() { // your code goes here int t; cin>>t; while(t--){     int a,b,c;     cin>>a>>b>>c;     if((a+b+c)==180)         cout<<"YES"; ...