Algorithm


Problem Name: beecrowd | 1985

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

MacPRONALTS

 

By Victor Jatobá, UNIME BR Brazil

Timelimit: 1

The MacPRONALTS is with a super promotion, exclusive to the contestants of the first Selective MaratonaTEC. But they had a problem, all runners were trying to buy at the same time, so this generated a very long queue. The worst is that the cashier girl no have calculator or a program to help her to calculate more quickly. You are the person that will help the girl and the MacPRONALTS increase their sells. Bellow has a menu day, that contains the product number and its value.

1001 | R$ 1.50

1002 | R$ 2.50

1003 | R$ 3.50

1004 | R$ 4.50

1005 | R$ 5.50

 

Input

 

The first entry is reported the number of purchased products (1 <= p <= 5). For each product follows the quantity (1 <= q <= 500) that the customer purchased.

Obs .: the product number will not be repeated.

 

Output

 

You must print the purchase amount with two decimal places.

 

 

 

Input Sample Output Sample

2

1001 2

1005 3

19.50

 

1

1003 500

1750.00

 

5

1001 500

1005 300

1003 23

1002 52

1004 44

2808.50

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include<stdio.h>
int main()
{
    int n,i,b;
    float a,s=0.0;
    scanf("%d",&n);
    for (i = 1; i  < = n; i++)
    {
        scanf ("%f %d",&a,&b);
        if (a == 1001)
            a = 1.50;
        if (a == 1002)
            a = 2.50;

        if (a == 1003)
            a = 3.50;

        if (a == 1004)
            a = 4.50;

        if (a == 1005)
            a = 5.50;
s=s+a*b;
    }
    printf ("%0.2f\n",s);

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

Input

x
+
cmd
2 1001 2 1005 3

Output

x
+
cmd
19.50

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
using namespace std;

int main()
{
    float n , p ,q , total = 0;
    cin >> n;
    for(int i = 0 ; i  <  n ; i++){
        cin >> p >> q;
        if(p == 1001){
            total+= 1.5*q;
        }
        else if(p == 1002){
            total+= 2.5*q;
        }
        else if(p == 1003){
            total+= 3.5*q;
        }
        else if(p == 1004){
            total+= 4.5*q;
        }
        else if(p == 1005){
            total+= 5.5*q;
        }
    }
    printf("%.2f\n" , total);

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

Input

x
+
cmd
2 1001 2 1005 3

Output

x
+
cmd
19.50
Advertisements

Demonstration


Previous
#1984 Beecrowd Online Judge Solution 1984 The Pronalância Puzzle Solution in C++, Java, Js and Python
Next
#1986 Beecrowd Online Judge Solution 1986 The Martian Solution in C, C++, Java, Js and Python