11717 - Energy Saving Microcontroller
来源:互联网 发布:学科评估网络空间安全 编辑:程序博客网 时间:2024/06/05 03:45
Problem E: Energy Saving Microcontroller
The rapid progress of the electronics era is mostly due to wide availability of microcontrollers. They are used in many devices, particularly in stand alone devices that need to do real time processing. Some common uses are in cell phones, hand held video games and pace makers. A lot of these stand alone devices run on internal battery power with no connection to external power source when in operation. Therefore it is critical that, the devices are able to minimize their power usage when idle. In this problem, you will be required to simulate the behavior of a simply designed microcontroller based device.
Input
The first line of input contains a positive integer T (≤10), whereT denotes the total number of scenarios to simulate. Each scenario starts with three positive numbersn (≤1000), i and k. Both i and k will fit in 32 bit signed integer. The nextn lines contain a positive integer each. These numbers will be in increasing order and will fit in 32 bit signed integer. These numbers indicate the time in microseconds when an instruction is sent to the microcontroller for execution. If the microcontroller is in active state, it will execute the instruction instantly. In the event the microcontroller is inactive, it will takek microseconds to activate itself and then it will process the instruction. If any instructions are sent during the activation period, those will be ignored. The microcontroller is active at the 0th microsecond, that is after it starts its operation. After that, if it doesn’t execute any instruction for at leasti microseconds, it goes into inactive state. Note that, the microcontroller may go into inactive state anytime it doesn’t receive an instruction for at leasti microseconds, after processing an instruction. If an instruction comes just when the device is about to go idle, the device will go idle and then the instruction will activate the device.
Output
For each input scenario, there will be one line of output. It will contain the case number followed by the number of times the microcontroller went into inactive state and the number of instructions that were ignored; the two numbers will be separated by a single space. Please look at sample output for exact formatting.
Sample Input
Output for Sample Input
3
1 2 3
1
2 2 3
10
11
2 2 1
10
11
Case 1: 0 0
Case 2: 1 1
Case 3: 1 0
#include<stdio.h>int main(){int t,count=1;scanf("%d",&t);while(t--){int n,p,k,i,x,a=0,b=0,ac=0;scanf("%d%d%d",&n,&p,&k);for(i=1;i<=n;i++) {scanf("%d",&x);if(x<ac) b++;else if(x>=ac+p){a++; ac=x+k;}if(x>ac) ac=x;}printf("Case %d: %d %d\n",count++,a,b);}return 0;}
- 11717 - Energy Saving Microcontroller
- [summ]Energy saving-Switching 3G_Wi-Fi_GPS
- Get Paid for Saving Energy with Demand Response
- Energy
- [summ] 基于MPTCP的无线通信节能方案/MPTCP-based Energy Saving Techs in Wireless Networks
- Flowers tide Weiyang, you is still there, just remember the energy-saving
- sw-microcontroller
- microprocess , microcontroller, and Soc
- 8042 Keyboard Microcontroller
- hcs12 microcontroller 笔记
- Energy Crisis
- Energy Conversion
- Energy Conversion
- Energy Conversion
- Energy Programming
- Energy Function
- Energy Minimization
- Microcontroller Programming: The Microchip PIC
- 背景图片加链接
- stm32之DMA彻底研究
- oracle学习笔记【持续更新】
- CG行业如何学编程:献给想要学编程的CG孩
- LA 4513 Stammering Aliens
- 11717 - Energy Saving Microcontroller
- stm32之DMA彻底研究(2)
- J2ee规范小结
- cscope emacs l138kernel
- stm32时钟分析
- 自定义标签改变标签体的内容
- EL表达式
- global_name 和dblink的关系
- 71