标签:
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1507
解题思路:这是一道模拟题,看了那么多人的代码,我觉得我的代码是最简的,哈哈,其实就是分数变幻的时候要计算灯管的亮数复杂一点,我就直接暴力咯
AC代码:
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; const int M=45000; int c[10]={6,2,5,5,4,5,6,3,7,6}; char a[5],b[5]; struct node { int x,y,z; }t[M]; int main() { int ca=1; while(1) { int i=-1,g=0,h=0,x1,y1,z1; long long sum=0; while(scanf("%s",a)!=EOF) { scanf("%d:%d:%d",&x1,&y1,&z1); i++; t[i].x=x1;t[i].y=y1;t[i].z=z1; int ans=(t[i].x-t[i-1].x)*3600+(t[i].y-t[i-1].y)*60+t[i].z-t[i-1].z; if(strcmp(a,"START")==0) continue; if(h>99){sum+=ans*(c[h/100]+c[h/10%10]+c[h%10]);} else if(h>9) {sum+=ans*(c[h/10]+c[h%10]);} else sum+=ans*(c[h%10]); if(g>99){sum+=ans*(c[g/100]+c[g/10%10]+c[g%10]);} else if(g>9) {sum+=ans*(c[g/10]+c[g%10]);} else {sum+=ans*(c[g%10]);} if(strcmp(a,"END")==0) break; int x2; scanf("%s%d",b,&x2); if(strcmp(b,"home")) h+=x2; else if(strcmp(b,"guest")) g+=x2; } if(i==-1) break; printf("Case %d: %lld\n",ca++,sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/www-cnxcy-com/p/5740836.html