题目链接: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. SQL小细节

    平时有些小细节,不留意的话很容易得到错误的答案,我们来看下下面的代码,看看你是否能答对呢? ) ,) SELECT @str = '中国CH',@info='MyTest' SELECT [字符串]= ...

  2. TP-LINK wr703n openwrt 挂载 U盘

    1.首先设置好DNS 2.点SYSTEM 点SOFTWARE 更新软件列表 3.安装下列软件: block-mount kmod-usb-storage kmod-fs-ext4 e2fsprogs ...

  3. DataGridView 绑定 List

    DataGridView 绑定 List<T> 不会自动更新 正确方式是将  List<T> 设置为 BindingList<T> 即可 (双向绑定)

  4. 关于for循环中的闭包问题

    还是昨天的那个简单的小项目,已经花了一天的时间了 - - .从&&的用法,到CSStext,到今天马上要谈的闭包(closure),通过一个小东西,真真发现了自己的各方面不足.昨天发完 ...

  5. 【AngularJS】——0.分析

    [引导分析]1.什么是AngularJS? 2.为什么要使用它? 3.应用场合? 4.基本思想? 5.四大核心特征? 6.优缺点是什么? 1.定义:AngularJS是一个用于设计动态web应用的前端 ...

  6. [LeetCode OJ] Largest Rectangle in Histogram

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  7. java学习之反射机制

    java语言区别于C,C++等准静态语言的最大特点就是java的反射机制.静态语言的最直接定义就是不能在运行时改变程序结构或变量的类型.按照这样的定义,python,ruby是动态语言,C,C++,J ...

  8. 【随记】SQL Server连接字符串参数说明

    废话不多说,请参见 SqlConnection.ConnectionString .

  9. GridView获取单个单元格的值

    0.GridView中的所有数据都存储在Rows集合中,可以通过Rows的Cell属性获取单个单元格的值:如果某个单元格包含其他控件,则通过使用单元格的 Controls 集合,从单元格检索控件:如果 ...

  10. Installing MySQL Server

    Installing MySQL Server Here we will learn how to Compile and Install the MySQL Server from source c ...