A Sweet Journey

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5477

Description

Master Di plans to take his girlfriend for a travel by bike. Their journey, which can be seen as a line segment of length L, is a road of swamps and flats. In the swamp, it takes A point strengths per meter for Master Di to ride; In the flats, Master Di will regain B point strengths per meter when riding. Master Di wonders:In the beginning, he needs to prepare how much minimum strengths. (Except riding all the time,Master Di has no other choice)

Input

In the first line there is an integer t (1≤t≤50), indicating the number of test cases.
For each test case:
The first line contains four integers, n, A, B, L.
Next n lines, each line contains two integers: Li,Ri, which represents the interval [Li,Ri] is swamp.
1≤n≤100,1≤L≤105,1≤A≤10,1≤B≤10,1≤Li<Ri≤L.
Make sure intervals are not overlapped which means Ri<Li+1 for each i (1≤i<n).
Others are all flats except the swamps.

Output

For each text case:
Please output “Case #k: answer”(without quotes) one line, where k means the case number counting from 1, and the answer is his minimum strengths in the beginning.

Sample Input

1
2 2 2 5
1 2
3 4

 

Sample Output

Case #1: 0

HINT

题意

有一个人,走沼泽地会损失ai点能量,走正常的会得到bi点能量

然后问你一开始需要多少能量才行?

题解:

扫一遍就好了,签到题

代码:

//qscqesze
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 100006
#define mod 1000000007
#define eps 1e-9
#define e exp(1.0)
#define PI acos(-1)
const double EP = 1E- ;
int Num;
//const int inf=0x7fffffff;
const ll inf=;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************* int a[maxn];
int main()
{
int t=read();
for(int cas=;cas<=t;cas++)
{
int n=read(),A=read(),B=read(),l=read();
memset(a,,sizeof(a));
for(int i=;i<=n;i++)
{
int L=read(),R=read();
for(int j=L;j<R;j++)
{
a[j]=;
}
}
int temp = ;
int ans = ;
for(int i=;i<l;i++)
{
if(a[i]==)
{
if(temp<A)
{
ans+=A-temp;
temp=;
}
else temp=temp-A;
}
else
temp+=B;
}
printf("Case #%d: %d\n",cas,ans);
}
}

HDU 5477 A Sweet Journey 水题的更多相关文章

  1. HDU 5477: A Sweet Journey

    A Sweet Journey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  2. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  3. HDU 5590 ZYB's Biology 水题

    ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  4. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  5. hdu 1005:Number Sequence(水题)

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  6. hdu 1018:Big Number(水题)

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  7. hdu 2041:超级楼梯(水题,递归)

    超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...

  8. HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

    Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...

  9. HDOJ(HDU) 2090 算菜价(简单水题、)

    Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...

随机推荐

  1. JADE平台入门

    相关介绍: JADE(Java Agent Development Framework,Java智能体开发框架) 用途: Java智能体开发框架 开发者: TILAB 主要功能: AMS.DF.ACC ...

  2. Oracle数据库生成UUID

    从Data Ghost的blog得知,原来可以用Oracle来生成UUID,做法很简单,如下: select sys_guid() from dual;  数据类型是 raw(16) 有32个字符.

  3. NK 1137: 石子合并问题

     1137: 石子合并问题 Time Limit: 1500 ms    Memory Limit: 10000 kB    Judge type: Multi-cases Total Submit ...

  4. mysqldump使用

    mysqldump常用于MySQL数据库逻辑备份. 1.各种用法说明 A. 最简单的用法: mysqldump -uroot -pPassword [database name] > [dump ...

  5. 3.2版uploadify详细例子(含FF和IE SESSION问题)

    最近做项目中碰到上传需要显示进度的问题,通过uploadfiy很好的解决了这个问题不过(IE9出现了按钮不能点击的问题,至今仍找不到良策) 在使用uploadfiy3.2版本时需要下载jquery.t ...

  6. Button的四种Click响应方法

    Button用得挺多的,在这整理了下它的事件处理方法,发现实现方法还不少,我比较喜欢第二种,你呢,最常用哪一种? 实现一: Button bt_Demo = (Button)findViewById( ...

  7. C/C++:原码、反码和补码

    正数的原码.反码和补码是一模一样的.   负数的反码的符号位跟原码一样,但其余各位取反. 负数的补码是其反码的最末位加1得到,即原码取反加1.   补码的补码就是原码.   浮点数的存储格式随着机器的 ...

  8. 常规页生命周期(class0620)

    常规页声明周期阶段 阶段                   说明 页请求 开始 页初始化 加载 验证 回发事件处理 卸载 生命周期事件 页事件               典型使用

  9. 全文检索- Oracle/MySql/达梦

    简单使用语法: MySql: ALTER TABLE dataset_ods ENGINE = MyISAM; //5.6后的InnoDB支持全文索引 ALTER TABLE dataset_ods ...

  10. 你知道C/S和B/S两种架构有什么区别吗?

    C/S和B/S,是再普通不过的两种软件架构方式,都可以进行同样的业务处理,甚至也可以用相同的方式实现共同的逻辑.既然如此,为何还要区分彼此呢?那我们就来看看二者的区别和联系. 一.C/S 架构     ...