[URI ONLINE JUDGE] – 2060 – Closing Tabs

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

 

solution:

 

<br /> 

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
int n;
int m2, m3, m4, m5;
m2 = m3 = m4 = m5 = 0;
cin >> n;

for(int i = 0; i < n; i++) {
int l;
cin >> l;

if(l % 2 == 0) m2++;
if(l % 3 == 0) m3++;
if(l % 4 == 0) m4++;
if(l % 5 == 0) m5++;
}
printf("%d Multiplo(s) de 2\n", m2);
printf("%d Multiplo(s) de 3\n", m3);
printf("%d Multiplo(s) de 4\n", m4);
printf("%d Multiplo(s) de 5\n", m5);

return 0;
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s