CSU_1507_超大型LED显示屏
来源:互联网 发布:淘宝联盟佣金查看插件 编辑:程序博客网 时间:2024/04/28 05:38
超大型LED显示屏
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 267 Solved: 145
[Submit][Status][Web Board]
Description
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:00SCORE 09:01:05 home 2SCORE 09:10:07 guest 3END 09:15:00START 09:00:00SCORE 10:00:00 home 1SCORE 11:00:00 home 1SCORE 12:00:00 home 1SCORE 13:00:00 home 1SCORE 14:00:00 home 1SCORE 15:00:00 home 1SCORE 16:00:00 home 1SCORE 17:00:00 home 1SCORE 18:00:00 home 1SCORE 19:00:00 home 1SCORE 20:00:00 home 1END 21:00:00
Sample Output
Case 1: 9672Case 2: 478800
HINT
一个模拟题就是当时没看清楚时间是不用显示的
才打了被注释掉那么多没用的代码
再仔细想想,时间都是成段的,因此就算要算的话
也应该预处理一些时间段,这样速度会快很多,一秒一秒的跑的话,太慢了
#include <iostream>#include <stdio.h>using namespace std; char s[10];char hg[10];int co[10]={6,2,5,5,4,5,6,3,7,6}; int inline chan(int nhor,int hor,int nmin,int mi,int nsec,int sec){ return (nhor-hor)*3600+(nmin-mi)*60+nsec-sec;} int scoco(int sc){ if(sc==0) return 6; int cos=0; while(sc>0) { cos+=co[sc%10]; sc/=10; } return cos;} //int ticoco(int t)//{// return co[t%10]+co[t/10];//}////int tico(int nhor,int hor,int nmin,int mi,int nsec,int sec)//{// int cos=0;int i=1;// while(1)// {// if(sec==59)// {// sec=0;// mi++;// if(mi==60)// {// mi=0;// hor++;// }// }// else// sec++;//// cout<<hor<<" "<<mi<<" "<<sec<<endl;// cos+=ticoco(sec)+ticoco(mi)+ticoco(hor);// i++;if(i>100)break;// if(nhor==hor&&nmin==mi&&nsec==sec)// break;// }// return cos;//} int main(){ int hor,mi,sec; int nhor,nmin,nsec; int ho,gu; int sc; int cost; int ca=1; while(scanf("%s",s)!=EOF) { scanf("%d:%d:%d",&hor,&mi,&sec); //cout<<hor<<" "<<mi<<" "<<sec<<endl; ho=0,gu=0;cost=0; while(1) { scanf("%s",s); if(s[0]=='E') { scanf("%d:%d:%d",&nhor,&nmin,&nsec); int time=chan(nhor,hor,nmin,mi,nsec,sec); //cout<<scoco(ho)<<" "<<scoco(gu)<<" "<<time<<endl; cost+=(scoco(ho)+scoco(gu))*time; //cost+=tico(nhor,hor,nmin,mi,nsec,sec); hor=nhor;mi=nmin;sec=nsec; break; } if(s[0]=='S') { scanf("%d:%d:%d%s%d",&nhor,&nmin,&nsec,hg,&sc); //cout<<nhor<<" "<<nmin<<" "<<nsec<<endl; int time=chan(nhor,hor,nmin,mi,nsec,sec); cost+=(scoco(ho)+scoco(gu))*time; //cost+=tico(nhor,hor,nmin,mi,nsec,sec); //cout<<"2"; hor=nhor;mi=nmin;sec=nsec; if(hg[0]=='h') ho+=sc; else gu+=sc; } } printf("Case %d: %d\n",ca++,cost); } return 0;}
0 0
- CSU_1507_超大型LED显示屏
- 超大型LED显示屏
- 超大型LED显示屏
- 超大型LED显示屏
- 超大型led显示屏
- O-超大型LED显示屏
- 超大型LED显示屏
- 超大型LED显示屏
- CSU 1507 超大型LED显示屏
- CSU 1507 超大型LED显示屏
- CSU-1507 超大型LED显示屏
- CSU OJ1507超大型LED显示屏
- 超大型LED显示屏(模拟)
- 湖南2014CPC 超大型LED显示屏
- CSU1507 超大型LED显示屏_模拟题
- CSU 1507: 超大型LED显示屏(数学啊)
- csu 1507: 超大型LED显示屏(要重新敲一遍)
- 湖南省第十届大学生计算机程序设计竞赛(原题) 第E题 超大型LED显示屏
- 华为上机试题3(简单密码)
- 工作中遇到的问题--View.Visibility
- 让Android的手机QQ崩溃未响应的指令---亲测有效果
- JavaScript学习小结
- 老人可适当发泄 有利于长寿
- CSU_1507_超大型LED显示屏
- 黑马程序员_java基础知识点
- Lua学习笔记--基本语法规则&控制流语句
- 电梯调度算法
- JAVA_SE系列:04.CLASSPATH环境变量的作用及详细分析
- 安卓应用程序之间的数据传递
- 线性表之循环链表和双链表
- sql语句经典
- 递归