Input
輸入包含不超過100組資料。每組資料第一行為”START hh:mm:ss”,表示比賽開始時刻為hh:mm:ss。最後一行為”END hh:mm:ss”,即比賽結束時刻。二者之間至少會有一個SCORE資訊,格式為”SCORE hh:mm:ss team score”,其中team要麼是”home”(主場)要麼是”guest”(客場), score表示得分,為1,2或者3。這些資訊保證按照時間從早到晚的順序排列,且任意兩條SCORE資訊的時刻均不相同。比賽開始時間不會早于9:00,結束時間不會晚于同一天的21:00。注意,如果比賽開始時間為09:00:00,結束時間為09:00:01,比賽長度為1秒鐘,而不是2秒鐘。
Output
對于每組資料,輸出測試點編号和總耗電量。
Sample Input
START 09:00:00
SCORE 09:01:05 home 2
SCORE 09:10:07 guest 3
END 09:15:00
START 09:00:00
SCORE 10:00:00 home 1
SCORE 11:00:00 home 1
SCORE 12:00:00 home 1
SCORE 13:00:00 home 1
SCORE 14:00:00 home 1
SCORE 15:00:00 home 1
SCORE 16:00:00 home 1
SCORE 17:00:00 home 1
SCORE 18:00:00 home 1
SCORE 19:00:00 home 1
SCORE 20:00:00 home 1
END 21:00:00
Sample Output
Case 1: 9672
Case 2: 478800
分析:模拟題
注意輸入的開始和結束
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
const double INF=+;
const double eps=e-;
typedef long long LL;
int fen[]= {,,,,,,,,,};
int fun(int n)
{
int ans=;
if(n==) return ;
while(n)
{
ans+=fen[n%10];
n/=;
}
return ans;
}
int main()
{
char str[];
int times[];
int ans,cas=;
int star,endd;
while(~scanf("%s",str))
{
int h,m,s;
if(!strcmp(str,"START"))
{
ans=;
mem(times,);
scanf("%d:%d:%d",&h,&m,&s);
star=*h+*m+s;
// printf("star=%d\n",star);
// continue;
}
while(~scanf("%s",str))
{
scanf("%d:%d:%d",&h,&m,&s);
if(!strcmp(str,"END"))
{
endd=*h+*m+s;
ans=ans+(endd-star)*(fun(times[])+fun(times[]));
// printf("ans=%d\n",ans);
break;
}
else
{
int score,t;
char str2[];
scanf("%s %d",str2,&score);
t=*h+*m+s;
// printf("t=%d\n",t);
ans=ans+(t-star)*(fun(times[])+fun(times[]));
// printf("ans=%d\n",ans);
star=t;
if(!strcmp(str2,"home"))
times[]+=score;
else times[]+=score;
}
}
printf("Case %d: %d\n",cas++,ans);
}
return ;
}