-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
30 lines (27 loc) · 716 Bytes
/
C.cpp
File metadata and controls
30 lines (27 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
double getPrice(int minutes){
double preco_total = 0;
preco_total += 0.00 * min(15, max(0, minutes));
minutes -= 15;
preco_total += 0.10 * min(45, max(0, minutes));
minutes -= 45;
preco_total += 0.08 * min(120, max(0, minutes));
minutes -= 120;
preco_total += 0.06 * min(4*60, max(0, minutes));
minutes -= 4*60;
preco_total += 0.02 * max(0, minutes);
return preco_total;
}
int main(){
std::ios::sync_with_stdio(false);
int minutes;
while (cin >> minutes && minutes){
double preco = getPrice(minutes);
cout << setprecision(2) << fixed << "Total: R$ " << preco << endl;
}
return 0;
}