CSU 1507 超大型LED显示屏 第十届湖南省赛题
题目链接: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显示屏 第十届湖南省赛题的更多相关文章
- CSU 1511 残缺的棋盘 第十届湖南省赛题
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 题目大意:在一个8*8的棋盘中,给你一个起点位置和一个终点位置,同时也给你一个陷阱 ...
- csuoj 1507: 超大型LED显示屏
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1507 1507: 超大型LED显示屏 时间限制: 1 Sec 内存限制: 128 MB 提交: ...
- 超大型 LED 显示屏
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11574&courseid=0 题目 E. 超大型 L ...
- 河南省第十届省赛 Plumbing the depth of lake (模拟)
title: Plumbing the depth of lake 河南省第十届省赛 题目描述: There is a mysterious lake in the north of Tibet. A ...
- 河南省第十届省赛 Intelligent Parking Building
title: Intelligent Parking Building 河南省第十届省赛 tags: [模拟,省赛] 题目描述: There is a new revolution in the pa ...
- 四川第十届省赛 A.Angel Beats bitset
四川第十届省赛 A.Angel Beats bitset 题目链接 题解参考:http://www.cnblogs.com/Aragaki/p/9142250.html 考虑用bitset来维护对于所 ...
- 福州大学第十届校赛 & fzu 2128最长子串
思路: 对于每个子串,求出 母串中 所有该子串 的 开始和结束位置,保存在 mark数组中,求完所有子串后,对mark数组按 结束位置排序,然后 用后一个的结束位置 减去 前一个的 开始 位置 再 减 ...
- 【河南第十届省赛-D】年终奖金
题目描述 ***公司承接了N个项目需要年底完成,每个项目有一定的难度系数.由于项目太多了,需要招聘大量的技术人员.要求每个技术人员至少完成K个项目. 考虑到有些项目之间相似性以及项目的难易程度,为了避 ...
- 【河南第十届省赛-B】情报传递
题目描述 抗日战争时期,在国共合作的大背景下,中共不断发展壮大,其情报工作也开始由获取警报性.保卫性信息,向获取军政战略性情报转变.各系统情报组织遵循"荫蔽精干,长期埋伏,积蓄力量,以待时机 ...
随机推荐
- C#中堆和栈的区别分析(有待更新总结2)
转载:http://blog.csdn.net/Zevin/article/details/5731965 线程堆栈:简称栈 Stack 托管堆: 简称堆 Heap 使用.Net框架开发程序的时候,我 ...
- js - 在拼接字符串中动态submit当前form
今天在做一个项目的时候, mapabc中的inforWindow中,如果是超链接a,不直接响应. 后来的解决方案是动态产生form,并调用summit方法.如下 自定义一个js函数: function ...
- 安装指南【win10下安装fedora】
系统安装 安装准备 系统:fedora .Win 10 硬件:U盘一枚.PC一台 软件:UltraISO 安装步骤 使用UltraISO将镜像写入U盘 window10使用磁盘管理,空出一个未分配的区 ...
- 注册表和ODBC
注册表使用的是树型体系结构,树中的每个结点称键.每个键也可以包含其他的键或子键.它允许进一步的分支,也即为值,它用来存储有效的数据.在注册表中,注册表用键来组织数据,一个键中的值用它们的名来 ...
- C#中标准Dispose模式的实现
http://www.cnblogs.com/luminji/archive/2011/03/29/1997812.html 需要明确一下C#程序(或者说.NET)中的资源.简单的说来,C#中的每一个 ...
- gcc/g++命令认识
gcc & g++是gnu中最主要和最流行的c & c++编译器 . g++用来针对c++的处理命令,以.cpp为后缀,对于c语言后缀名一般为.c.这时候命令换做gcc即可. 下面以T ...
- WPF之 XAML集合项简单演示
我们直接通过xaml文件演示一个简单的xaml集合项: <Window x:Class="WPF_XAML集合项.MainWindow" xmlns="http:/ ...
- codeforces 361 C - Mike and Chocolate Thieves
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Bad ...
- cygwin使用
Cygwin是一个在windows平台上运行的类UNIX模拟环境,是cygnus solutions公司开发的自由软件(该公司开发的著名工具还有eCos,不过现已被Redhat收购). 它对于学习UN ...
- 用word2013写博客
第一次使用,添加博客账户时碰到一个奇怪的问题,先输入用户名,然后密码只能输入两个字符,后来先输入密码再输入用户名才解决,很神奇~