超大型LED显示屏

xiaoxiao2021-02-27  157

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

这题呢就是比拼耐心了,题目其实不是很难,关键的就是讲他的0-9存进来的时候直接变成需要消耗的电能

#include<cstdio> #include<cstring> #include<queue> #include<stack> #include<iostream> using namespace std; struct time {     int h,m,s; }times; int snake,edg = 0,skt = 0; int fenshu[] = {6,2,5,5,4,5,6,3,7,6}; int summer(int x) {     int rng = 0;     if(x == 0)         return 6;     else     {         while(x)         {             rng+=fenshu[x];             x/=10;         }     }     return rng; } int main() {     int sum = 0,hour,min,s,case1 =1;     char xx[10];     while(~scanf("%s",xx))     {         if(xx[1] == 'T')         {             scanf("%d:%d:%d",&hour,&min,&s);             times.h = hour;             times.m = min;             times.s = s;         }         else if(xx[1] == 'C')         {             char team[10];             int suml;             scanf("%d:%d:%d %s %d",&hour,&min,&s,team,&snake);             suml=(hour*3600-times.h*3600)+(min*60-times.m*60)+s-times.s;             times.h = hour;             times.m = min;             times.s = s;             int ll = summer(edg);             int rr = summer(skt);             sum+=suml*ll+suml*rr;             if(team[0] == 'h')                 edg+=snake;             else                 skt+=snake;         }         else if(xx[1] == 'N')         {             scanf("%d:%d:%d",&hour,&min,&s);             int sumr;             sumr=(hour*3600-times.h*3600)+(min*60-times.m*60)+s-times.s;             int ll = summer(edg);             int rr = summer(skt);             sum+=sumr*ll+sumr*rr;             printf("Case %d: %d\n",case1,sum);             sum = 0;             edg = 0;             skt = 0;             case1++;         }     }     return 0; }
转载请注明原文地址: https://www.6miu.com/read-16084.html

最新回复(0)