Algorithm


Problem Name: beecrowd | 2060

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2060

Bino's Challenge

 

By Thalyson Nepomuceno, UECE BR Brazil

Timelimit: 1

Bino and Cino are close friends. Bino likes to create mathematical challenges to Cino. This time, Bino created a list of numbers and asked to Cino: How many numbers are multiples of 2, 3, 4 and 5?

This challenge looks simple, but when the list contains many numbers, Cino makes some miscalculations. To help Cino, make a program to solve the Bino's Challenge.

 

Input

 

The first line of input consists of an integer N (1 ≤ N ≤1000), representing the amount of numbers in the Bino's list.

The second line contains N integers Li (1 ≤ Li ≤ 100), representing the numbers of the Bino's list.

 

Output

 

Print the amount of multiples of 2, 3, 4 and 5 in the list. Note the formatting of the output in the output sample, because it must be followed strictly. "Multiplo(s)" means "Multiple(s)" in English, but you must print the message in Portuguese.

 

 

 

Input Sample Output Sample

5
2 5 4 20 10

4 Multiplo(s) de 2
0 Multiplo(s) de 3
2 Multiplo(s) de 4
3 Multiplo(s) de 5

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(void)

{
    int n, i, two=0, three=0, four=0, five=0;

    scanf("%i", &n);

    int arr[n];

    for (i = 0; i  <  n; ++i)
        scanf("%i", &arr[i]);

    for (i = 0; i  <  n; ++i)
    {
        if (arr[i]%2==0)
            ++two;

        if (arr[i]%3==0)
            ++three;

        if (arr[i]%4==0)
            ++four;

        if (arr[i]%5==0)
            ++five;
    }

    printf("%i Multiplo(s) de 2\n%i Multiplo(s) de 3\n%i Multiplo(s) de 4\n%i Multiplo(s) de 5\n", two, three, four, five);

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 2 5 4 20 10

Output

x
+
cmd
4 Multiplo(s) de 2 0 Multiplo(s) de 3 2 Multiplo(s) de 4 3 Multiplo(s) de 5

#2 Code Example with C++ Programming

Code - C++ Programming


#include<stdio.h>

int main()
{

    int test,ar,cnt2=0,cnt3=0,cnt4=0,cnt5=0,i;
    scanf("%d",&test);
    for(i = 0; i  <  test; i++)
    {
        scanf("%d",&ar);
        if(ar%2==0)cnt2++;
        if(ar%3==0)cnt3++;
        if(ar%4==0)cnt4++;
        if(ar%5==0)cnt5++;
    }
    printf("%d Multiplo(s) de 2\n",cnt2);
    printf("%d Multiplo(s) de 3\n",cnt3);
    printf("%d Multiplo(s) de 4\n",cnt4);
    printf("%d Multiplo(s) de 5\n",cnt5);

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 2 5 4 20 10

Output

x
+
cmd
4 Multiplo(s) de 2 0 Multiplo(s) de 3 2 Multiplo(s) de 4 3 Multiplo(s) de 5

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const A = lines.shift().split(" ");
const numbers = lines.shift().split(" ");
let mult2 = 0;
let mult3 = 0;
let mult4 = 0;
let mult5 = 0;

for(let i = 0; i  <  numbers.length, i < parseInt(A); i++){
  if(numbers[i] % 2 == 0){
    mult2++;
  }
  if(numbers[i] % 3 == 0){
    mult3++;
  }
  if(numbers[i] % 4 == 0){
    mult4++;
  }
  if(numbers[i] % 5 == 0){
    mult5++;
  }
}

console.log(`${mult2} Multiplo(s) de 2\n${mult3} Multiplo(s) de 3\n${mult4} Multiplo(s) de 4\n${mult5} Multiplo(s) de 5`);
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 2 5 4 20 10

Output

x
+
cmd
4 Multiplo(s) de 2 0 Multiplo(s) de 3 2 Multiplo(s) de 4 3 Multiplo(s) de 5

#4 Code Example with Python Programming

Code - Python Programming


N = int(input())

multiple_two = 0
multiple_three = 0
multiple_for = 0
multiple_five = 0

values = input().split(' ')
values_correctly = values[:N]
for i in range(N):
    values_correctly[i] = int(values_correctly[i])
    if(values_correctly[i] % 2 ==0):
        multiple_two+=1
    if(values_correctly[i] % 3 ==0):
        multiple_three+=1
    if(values_correctly[i] % 4 ==0):
        multiple_for+=1
    if(values_correctly[i] % 5 ==0):
        multiple_five+=1

print('{0} Multiplo(s) de 2'.format(multiple_two))
print('{0} Multiplo(s) de 3'.format(multiple_three))     
print('{0} Multiplo(s) de 4'.format(multiple_for))     
print('{0} Multiplo(s) de 5'.format(multiple_five))
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 2 5 4 20 10

Output

x
+
cmd
4 Multiplo(s) de 2 0 Multiplo(s) de 3 2 Multiplo(s) de 4 3 Multiplo(s) de 5
Advertisements

Demonstration


Previous
#2059 Beecrowd Online Judge Solution 2059 Odd, Even or CheatingSolution in C, C++, Java, Js and Python
Next
#2061 Beecrowd Online Judge Solution 2061 Closing Tabs Solution in C, C++, Java, Js and Python