题目链接: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=;
int c[]={,,,,,,,,,};
char a[],b[];
struct node
{
int x,y,z;
}t[M];
int main()
{
int ca=;
while()
{
int i=-,g=,h=,x1,y1,z1;
long long sum=;
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-].x)*+(t[i].y-t[i-].y)*+t[i].z-t[i-].z;
if(strcmp(a,"START")==) continue;
if(h>){sum+=ans*(c[h/]+c[h/%]+c[h%]);}
else if(h>) {sum+=ans*(c[h/]+c[h%]);}
else sum+=ans*(c[h%]);
if(g>){sum+=ans*(c[g/]+c[g/%]+c[g%]);}
else if(g>) {sum+=ans*(c[g/]+c[g%]);}
else {sum+=ans*(c[g%]);}
if(strcmp(a,"END")==) break;
int x2;
scanf("%s%d",b,&x2);
if(strcmp(b,"home")) h+=x2;
else if(strcmp(b,"guest")) g+=x2;
}
if(i==-) break;
printf("Case %d: %lld\n",ca++,sum);
}
return ;
}

改善代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
const int M=;
int c[]={,,,,,,,,,};
char a[],b[];
long long sum;
struct node
{
int x,y,z;
}t[M];
int work(int x)
{
if(x==) return c[];
int s=;
while(x)
{
s+=c[x%];
x/=;
}
return s;
}
int main()
{
int ca=;
while()
{
int i=-,g=,h=,x1,y1,z1;
sum=;
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-].x)*+(t[i].y-t[i-].y)*+t[i].z-t[i-].z;
if(strcmp(a,"START")==) continue;
sum+=ans*(work(h)+work(g));
if(strcmp(a,"END")==) break;
int x2;
scanf("%s%d",b,&x2);
if(strcmp(b,"home")) h+=x2;
else if(strcmp(b,"guest")) g+=x2;
}
if(i==-) break;
printf("Case %d: %lld\n",ca++,sum);
}
return ;
}

CSU 1507 超大型LED显示屏 第十届湖南省赛题的更多相关文章

  1. CSU 1511 残缺的棋盘 第十届湖南省赛题

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 题目大意:在一个8*8的棋盘中,给你一个起点位置和一个终点位置,同时也给你一个陷阱 ...

  2. csuoj 1507: 超大型LED显示屏

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1507 1507: 超大型LED显示屏 时间限制: 1 Sec  内存限制: 128 MB 提交:  ...

  3. 超大型 LED 显示屏

    http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11574&courseid=0 题目 E. 超大型 L ...

  4. 河南省第十届省赛 Plumbing the depth of lake (模拟)

    title: Plumbing the depth of lake 河南省第十届省赛 题目描述: There is a mysterious lake in the north of Tibet. A ...

  5. 河南省第十届省赛 Intelligent Parking Building

    title: Intelligent Parking Building 河南省第十届省赛 tags: [模拟,省赛] 题目描述: There is a new revolution in the pa ...

  6. 四川第十届省赛 A.Angel Beats bitset

    四川第十届省赛 A.Angel Beats bitset 题目链接 题解参考:http://www.cnblogs.com/Aragaki/p/9142250.html 考虑用bitset来维护对于所 ...

  7. 福州大学第十届校赛 & fzu 2128最长子串

    思路: 对于每个子串,求出 母串中 所有该子串 的 开始和结束位置,保存在 mark数组中,求完所有子串后,对mark数组按 结束位置排序,然后 用后一个的结束位置 减去 前一个的 开始 位置 再 减 ...

  8. 【河南第十届省赛-D】年终奖金

    题目描述 ***公司承接了N个项目需要年底完成,每个项目有一定的难度系数.由于项目太多了,需要招聘大量的技术人员.要求每个技术人员至少完成K个项目. 考虑到有些项目之间相似性以及项目的难易程度,为了避 ...

  9. 【河南第十届省赛-B】情报传递

    题目描述 抗日战争时期,在国共合作的大背景下,中共不断发展壮大,其情报工作也开始由获取警报性.保卫性信息,向获取军政战略性情报转变.各系统情报组织遵循"荫蔽精干,长期埋伏,积蓄力量,以待时机 ...

随机推荐

  1. A题笔记(1)

    #include <stdlib.h> exit(); #include <stdlib.h> 是 exit(0) 必须的头文件 否则会出现 exit was not decl ...

  2. Java Map集合按照key和value排序之法

    一.理论基点 Map是键值对的集合接口,它的实现类主要包括:HashMap,TreeMap,Hashtable以及LinkedHashMap等. TreeMap:基于红黑树(Red-Black-Tre ...

  3. java_设计模式_组合模式_Composite Pattern(2016-08-12)

    概念: 组合模式(Composite Pattern)将对象组合成树形结构以表示“部分-整体”的层次结构,组合模式使得用户对单个对象和组合对象的使用具有一致性. 有时候又叫做部分-整体模式,它使我们树 ...

  4. list集合练习一

    package com.java.c.domain; public class Person { private String name; private int age; public Person ...

  5. C++类型转换总结 转

    一.前言: C风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是: TYPE b = (TYPE)a. C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用. con ...

  6. hibernate一些方法

    session.flush() 同步缓存与数据库数据 session.evict(obj) 关闭指定对象缓存 session.clear() 关闭所有缓存 iterator(会把数据放入缓存)  下次 ...

  7. js简版定时器

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  8. IS about 64bit system

    This function supports the 64-bit parts of the registry by using the REGDB_OPTION_WOW64_64KEY option ...

  9. Java实现单向链表

    /* 先定义一个Node类用来存储节点的值域和指针域 * 即当前节点中的值和后面节点的方法 * 在C中就是相当与定义一个结构体类型一个数据域和指针域的方法 */class LNode{//这个写法已经 ...

  10. wordpress 如何从后台数据库修改theme(图文教程)

    我们在wordpress主题theme配置的时候,会从网站上下载比较流行的theme,使自己的blog看着很酷,也有不顺利的时候,你下载的theme有bug或者下载包出问题了,安装过后你的web页面不 ...