https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=81
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
double cost[5][3] = {
{0.10, 0.06, 0.02},
{0.25, 0.15, 0.05},
{0.53, 0.33, 0.13},
{0.87, 0.47, 0.17},
{1.44, 0.80, 0.30}
};
main(){
int a, b, c, d, x, y;
int i, j;
double sum;
char str[10], ch;
while (scanf("%c",&ch) && ch != '#'){
cin >> str >> a >> b >> c >> d;
getchar();
sum = 0;
int minu[1440] = {0}, time[3] = {0};
x = a * 60 + b;
y = c * 60 + d;
if (y <= x){
for (i = 0; i < y; i++)
minu[i] = 1;
for (i = x; i < 1440; i++)
minu[i] = 1;
}
else{
for (i = x; i < y; i++)
minu[i] = 1;
}
for (i = 0; i < 480; i++){
if (minu[i] == 1)
time[2]++;
}
for (i = 480; i < 1080; i++){
if (minu[i] == 1)
time[0]++;
}
for (i = 1080; i < 1320; i++){
if (minu[i] == 1)
time[1]++;
}
for (i = 1320; i < 1440; i++){
if (minu[i] == 1)
time[2]++;
}
sum = time[0] * cost[ch - 'A'][0] + time[1] * cost[ch - 'A'][1] + time[2] * cost[ch - 'A'][2];
cout << setw(10) << str << setw(6) << time[0] << setw(6) << time[1] << setw(6) << time[2] << setw(3) << ch << setw(8) << fixed << setprecision(2) << sum << endl;
}
}
留言列表