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点能量

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

题解:

扫一遍就好了,签到题

代码:

  1. //qscqesze
  2. #pragma comment(linker, "/STACK:1024000000,1024000000")
  3. #include <cstdio>
  4. #include <cmath>
  5. #include <cstring>
  6. #include <ctime>
  7. #include <iostream>
  8. #include <algorithm>
  9. #include <set>
  10. #include <bitset>
  11. #include <vector>
  12. #include <sstream>
  13. #include <queue>
  14. #include <typeinfo>
  15. #include <fstream>
  16. #include <map>
  17. #include <stack>
  18. typedef long long ll;
  19. using namespace std;
  20. //freopen("D.in","r",stdin);
  21. //freopen("D.out","w",stdout);
  22. #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
  23. #define maxn 100006
  24. #define mod 1000000007
  25. #define eps 1e-9
  26. #define e exp(1.0)
  27. #define PI acos(-1)
  28. const double EP = 1E- ;
  29. int Num;
  30. //const int inf=0x7fffffff;
  31. const ll inf=;
  32. inline ll read()
  33. {
  34. ll x=,f=;char ch=getchar();
  35. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  36. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  37. return x*f;
  38. }
  39. //*************************************************************************************
  40.  
  41. int a[maxn];
  42. int main()
  43. {
  44. int t=read();
  45. for(int cas=;cas<=t;cas++)
  46. {
  47. int n=read(),A=read(),B=read(),l=read();
  48. memset(a,,sizeof(a));
  49. for(int i=;i<=n;i++)
  50. {
  51. int L=read(),R=read();
  52. for(int j=L;j<R;j++)
  53. {
  54. a[j]=;
  55. }
  56. }
  57. int temp = ;
  58. int ans = ;
  59. for(int i=;i<l;i++)
  60. {
  61. if(a[i]==)
  62. {
  63. if(temp<A)
  64. {
  65. ans+=A-temp;
  66. temp=;
  67. }
  68. else temp=temp-A;
  69. }
  70. else
  71. temp+=B;
  72. }
  73. printf("Case #%d: %d\n",cas,ans);
  74. }
  75. }

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. Android开发之ListView-SimpleAdapter的使用

    SimpleAdapter: SimpleAdapter(Context context, List<? extends Map<String, ?>> data, int r ...

  2. CQOIX2007余数之和

    朴素能得个差不多吧…… 这题改进算法真恶心 pascal一直过不了,难道非得转c++? 代码:(pascal) var n,k,i,l,r,m:longint; ans:qword; function ...

  3. (转)MySQL数据库引擎ISAM MyISAM HEAP InnoDB的区别

    转自:http://blog.csdn.net/nightelve/article/details/16895917 MySQL数据库引擎取决于MySQL在安装的时候是如何被编译的.要添加一个新的引擎 ...

  4. 【js与jquery】电子邮箱、手机号、邮政编码的正则验证

    //验证邮政编码 $("#postcode").blur(function(){ //获取邮政编码 var postcode=$("#postcode").va ...

  5. create a C# context menu from code

    I try the one of your approach, it works well in my computer. Below is my code: public void AddConte ...

  6. 11、四大组件之二-Service高级(二)Native Service

    一.Service的分类 1.1>Android Service 使用Java编写在JVM中运行的服务 1.2>Native Service 使用C/C++完成的服务,一般在系统开始时完成 ...

  7. This Android SDK requires Android Developer Toolkit version 23.0.0 or above

    2014-07-05 12:58 6445人阅读 评论(1) 收藏 举报 This Android SDK requires Android Developer Toolkit version 23. ...

  8. HDU 1495 非常可乐 BFS搜索

    题意:有个为三个杯子(杯子没有刻度),体积为s,n,m,s=m+n, 刚开始只有体积为s的杯子装满可乐,可以互相倒,问你最少的次数使可乐均分,如果没有结果,输出-1; 分析:直接互相倒就完了,BFS模 ...

  9. java web接收POST数据

    新建一个ServerForPOSTMethod的动态网站工程

  10. 编译驱动时出现"Cannot open file trace.h"错误

    编译驱动时出现"Cannot open file trace.h"错误 如题,用VS2013编译驱动是出现上述错误,原来是开启了WPP追踪导致的: 解决方案: 右键项目名-属性-W ...