Codeforces Beta Round #10 / 10A Power Consumption Calculation (模拟)

Household Electric Power Consumption-数据集 Household Electric Power ConsumptionThis archive contains 2075259 measurements gathered between December 2006 and November 2010 (47 months). 立即下载

A. Power Consumption Calculation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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].

Input

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

Output the answer to the problem.

Sample test(s)
input
1 3 2 1 5 10
0 10
output
30
input
2 8 4 2 5 10
20 30
50 100
output
570

注意t2是接在t1后面算的。


完整代码:

/*30ms,0KB*/

#include<cstdio>

int main()
{
	int n, p1, p2, p3, t1, t2;
	scanf("%d%d%d%d%d%d", &n, &p1, &p2, &p3, &t1, &t2);
	int p1pow = t1 * p1, p2pow = t2 * p2;
    int l, r, l2, r2;
	scanf("%d%d", &l, &r);
	int sum = (r - l) * p1;
	while (--n)
	{
		scanf("%d%d", &l2, &r2);
		int mid = l2 - r ;
		if (mid <= t1)
			sum += mid * p1;
		else
		{
			sum += p1pow;
			mid -= t1;
			if (mid <= t2)
				sum += mid * p2;
			else
				sum += p2pow + (mid - t2) * p3;
		}
		sum += (r2 - l2) * p1;
		l = l2;
		r = r2;
	}
	printf("%d", sum);
	return 0;
}



household_power_consumption_1000.zip 描述家庭用电情况的数据,这是一个压缩包,解压出来是.txt文件,就是代码中引用的数据。这里是用到了1000条数据。 立即下载

相关推荐

解密m3u8视频合并:从猫抓插件到本地文件修改全流程

本文详细解析了m3u8视频合并的全流程,特别针对加密视频片段提供了解决方案。从使用猫抓插件捕获m3u8文件地址,到利用N_m3u8DL-CLI工具自动下载、解密并合并ts片段,手把手教你处理AES-128加密等常见问题,最终生成完整的本地MP4文件,适合需要备份或处理流媒体资源的用户。

weixin_29290947的博客 1382

2805. Power Consumption Calculation耗电计算(c++)

题目描述: Power Consumption Calculation 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 tim

qq_43252441的博客 807

物理学建模及仿真平台Chrono安装

Chrono是一个基于物理学的建模和仿真基础设施,它是在C++中实现的独立于平台的开源设计。一个projectchrono库可以嵌入到一个软件项目中,例如在可变形地形上运行的轮式和履带式车辆、机器人、机械电子系统、顺应性机构和流体固体相互作用现象。系统可以由刚性和柔性/顺应性部件组成,并带有约束、电机和接触;部件可以具有三维形状,以便进行碰撞检测。然而安装还是出现了一些问题,所以在此总结。已经装好visual studio。

Already8888的博客 6509

CodeForces刷题:Power Consumption Calculation、Increasing Sequence

记录CodeForces刷题QAQ。

林一百二十八的博客 738

[官方培训]07-UE材质基础 孙丹璐 Epic 笔记

勾选允许自定义深度写入再在模型上勾选然后可以通过Scene Texture节点拿到渲染的自定义深度信息,有了自定义深度信息就可以与当前渲染的像素深度进行对比,自定义深度信息存放的是最靠近我们的深度,如果当前像素离自定义深度比较远我们就不要这个像素。效果如下这种方案的缺点也很明显,因为这样看不到第二层的透明了,如果是两层的半透明的裙摆,这样就看不到第二层的裙摆了。对于半透明排序问题最根本能解决的还是光线追踪,ue5中又加入了OIT(基于像素的排序)。官方透明材质的理解和应用。

Tcohneyn的博客 1572

GPMC开发笔记(TI开发者推荐笔记)

因为gpmc(General-Purpose Memory Controller)是TI特有的驱动,gpmc的资料比较少,本人开发gpmc驱动算是摸了很多石头过河的。所以想通过这遍文章可以给也做GPMC驱动开发的后来者有一点参考价值。文章如有瑕疵也请各位批评改正。 1.GPMC介绍 gpmc主要用于与nandflash,norflash,fpga进行通信。在这里主要介绍gpmc16位数据和地址线不复用nor模式下的通信。 注意:在这种模式下gpmc_a[0]引脚是没法使用的 1.1GPMC信号线

weixin_44316996的博客 7519

power consumption/capacity unit 耗电 /电池容量

1: 电池容量会用: mwh(毫瓦时)   mah (毫安时)表示 例如:2000mah:  表示如果每小时设备 电流为200mA,那么可以用10个小时(200ma*10h = 2000mah)             2000mwh: 同理 2:  由上可以看出,表示一个设备某种状态下的耗电流,可以用功率mw,或者电流ma表示 某种状态可以是:睡眠状态,normal状态(通话状态,播

tangkegaga的专栏 2322

从URDF到仿真动画:基于Simulink、Simscape与S-Function的机械臂一体化建模与控制

本文详细介绍了从URDF文件到高保真仿真动画的一体化机械臂建模与控制流程。通过整合Simulink、Simscape与S-Function,构建了包含物理特性的虚拟机械臂模型,并实现了自适应滑模等高级控制算法的嵌入与验证。该流程打通了从机械设计到控制算法验证的闭环,为机器人开发提供了高效的仿真平台。

cnn8visionary的博客 706

模拟——Power Consumption Calculation

有一台电脑,在活跃状态下,每秒钟耗能P1,在没人碰之后的T1秒后,进入休息状态,每秒钟耗能P2,如果再有T2秒没人碰的话,就会进入睡眠状态,每秒钟耗能P3。给你这个人碰电脑的区间时间,问你这台电脑的耗能是多少。

m0_60738889的博客 891

静态时序分析—伪路径(set_false_path)

set_false_path应用场景

m0_61544122的博客 2万+

22、忆阻器、忆阻系统及其神经形态应用综述

本文综述了忆阻器与忆阻系统的理论基础及其在神经形态系统中的广泛应用。从忆阻器的基本定义出发,介绍了其在非线性电路、存储技术、通信和神经形态计算等领域的应用潜力。重点探讨了基于忆阻器的神经元模型(如Hodgkin-Huxley、FitzHugh-Nagumo和Hindmarsh-Rose模型)、突触实现方式及多种忆阻神经网络架构,包括细胞神经网络、脉冲神经网络和递归神经网络等。此外,深入分析了忆阻器在水库计算中的理论研究与硬件实现进展,展示了其在时间序列处理、模式识别和信号预测等方面的优异性能。尽管忆阻技术前

kiwi8的博客 211

通师高专科技创新社周赛Round 15

CF10A Power Consumption Calculation 题目链接 题意 给你该人碰电脑的区间,问电脑的总的耗能是多少 思路 1.分情况 是一个区间还是多个区间 2. 多个区间时,除了第一个区间其余的区间的状态的时间对应的耗能 3.最后所有的耗能进行相加 坑点 无 代码 #include<bits/stdc++.h> using namespace std; int n,p1,p2,p3,t1,t2; int l,r,s; int ans=0;

m0_63353853的博客 381

基于Simulink的电源纹波抑制仿真

电源纹波(Power Supply Ripple)是指直流电源输出中存在的交流分量。纹波的存在会导致电压波动,进而影响负载设备的性能和寿命。为了确保高质量的电源输出,通常需要设计有效的滤波电路来抑制纹波。Simulink 提供了一个强大的仿真环境,可以用来设计、分析和验证电源纹波抑制方案。本教程将详细介绍如何使用 Simulink 进行电源纹波抑制的仿真实例。通过本教程,我们详细介绍了如何使用 Simulink 进行电源纹波抑制的仿真实例。背景介绍:理解电源纹波及其对电力电子系统的影响。仿真建模过程。

xiaoheshang_123的博客 515

Codeforces Beta Round #10 A. Power Consumption Calculation (模拟)

题目链接:http://www.codeforces.com/contest/10/problem/A题意:有一台电脑,在活跃状态下,每秒钟耗能p1,在没人碰之后的t1秒后,进入休息状态,每秒钟耗能p2,如果再有t3秒没人碰的话,就会进入睡眠状态,每秒钟耗能p3,给你这个人碰电脑的区间时间,问你这台电脑的耗能是多少思路:因为区间很小,所以说直接标记,然后检查就好了ac代码:#include<stdi

滴水穿石,慢慢积累,总会有成果 471

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces Beta Round #10 A. Power Consumption Calculation 水题

A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal ...

weixin_34248705的博客 175

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

A. Power Consumption Calculation

A. Power Consumption Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTom is interested in power consumption of his favourite laptop. His

chaideyipi 719

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

算法成长之路------CF10A Power Consumption Calculation

学习目标:算法学习-Day10 题库: 洛谷题库 每天保持发布一篇Java或C算法题解! 题目: 有一台电脑,在活跃状态下,每秒钟耗能 P1,在没人碰之后的 T1 秒后,进入休息状态,每秒钟耗能 P2,如果再有 T2 秒没人碰的话,就会进入睡眠状态,每秒钟耗能 P3。 给你这个人碰电脑的区间时间,问你这台电脑的耗能是多少 输入格式: n,t1,t2,p1,p2,p3,其中n表示这个人用了几次电脑。 输出格式: 输出效率 样例 1 : 输入: 1 3 2 1 5 10 0 10 输出: 30 样例 2 :

m0_51507612的博客 344

Codeforces 10A-Power Consumption Calculation(模拟)

A. Power Consumption Calculation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tom is interested in power

Orz~~Orz 1815

CodeForces 10A Power Consumption Calculation

思路:水题 #include using namespace std; #define LL long long const int maxn = 105; int n,p1,p2,p3,t1,t2; struct Node { int s; int t; }nodes[maxn]; int vis[3000]; int main() { scanf("%d%d%d%d%d%

围巾的ACM博客 555

Python解决codeforces ---- 4

第一题 10A A. Power Consumption Calculation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tom ...

844604778 306

【codeforces】题解 CF10A Power Consumption Calculation(题解)

模拟 排序 概率论 解模拟题的方法: (1)认真仔细的读懂题目。模拟题的描述通常都比较详细,篇幅一般都比较长,应该边阅读边将有关的条件一条条地记录下来,阅读完成后要反复核对,绝对不能有错漏。 (2)建立各个条件之间的关系,最好用一些简明的表格列出。 (3)认真分析这些关系,并建立这些关系的数学模型。 (4)规划各个模块的结构,用相应的语言、逐步求精的方法描述具体的算法。 (5)编写程序,调试并运行...

zhaoweiming2019的博客 415

CF 10A Power Consumption Calculation

shui #include using namespace std; int main() { int n,p1,p2,p3,t1,t2; int data_time[110][2]; while(cin>>n>>p1>>p2>>p3>>t1>>t2) { for(int i = 1;i <= n;i ++) cin>

WORK HARD IN SILENCE LET SUCCESS MAKE THE NOISE 536

【水分段函数】#10 A.Power Consumption Calculation

A. Power Consumption Calculation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tom is interested in power

CD's Coding 1152

codeforce 10A

http://vjudge.net/contest/view.action?cid=47807#problem/A Description Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consum

ACM,再见! 773
上一篇: 编程中无穷大常量的设定技巧
下一篇: Codeforces Round #136 (Div. 2) / 221A Little Elephant and Function (数学)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值