Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods[l1,?r1],?[l2,?r2],?...,?[ln,?rn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,?rn].
The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1?≤?n?≤?100,?0?≤?P1,?P2,?P3?≤?100,?1?≤?T1,?T2?≤?60). The following nlines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0?≤?li?<?ri?≤?1440,ri?<?li?+?1 for i?<?n), which stand for the start and the end of the i-th period of work.
Output the answer to the problem.
1 3 2 1 5 10
0 10
30
2 8 4 2 5 10
20 30
50 100
570
/* ***********************************************
Author :
Created Time :2015/6/2 16:01:09
File Name :2.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int s[maxn];
int sum;
int n,p1,p2,p3,t1,t2;
int getsum(int t){
if(t<=t1)return p1*t;
else if(t>t1&&t<=t1+t2)return p2*(t-t1)+t1*p1;
else if(t>t1+t2)return p3*(t-t2-t1)+p2*t2+p1*t1;
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
while(cin>>n>>p1>>p2>>p3>>t1>>t2){
int a,b;
int j=0;
int t;
sum=0;
for(int i=1;i<=n;i++){
cin>>a>>b;
if(i==1)t=a;
sum+=b-a;
s[j++]=a-t;
t=b;
}
sum*=p1;
for(int i=1;i<j;i++){
sum+=getsum(s[i]);
//cout<<"//"<<getsum(s[i])<<endl;
}
cout<<sum<<endl;
}
return 0;
}
本文介绍了一个模拟笔记本电脑在不同工作模式下能耗计算的方法。通过输入笔记本电脑的工作周期和三种模式下的功耗参数,可以计算出笔记本电脑在指定时间段内的总能耗。

5458

被折叠的 条评论
为什么被折叠?



