nyoj 1242 Interference Signal (河南省第八届acm程序设计大赛)
2016-01-26 23:25
393 查看
题目1242
题目信息
运行结果
本题排行
讨论区
难度:1
描述
Dr.Kong’s laboratory monitor some interference signals. The interference signals can be digitized into a series of positive integer. May be, there are
N integers a1,a2,…,an.
Dr.Kong wants to know the
average strength of a contiguous interference signal block.
the block must contain at least M integers.
Please help Dr.Kong to calculate the
maximum average strength, given the constraint.
输入The input contains K test cases. Each test case specifies:
* Line 1: Two space-separated integers, N and M.
* Lines2~line N+1: ai (i=1,2,…,N)
1 ≤ K≤ 8, 5 ≤ N≤ 2000, 1 ≤ M ≤ N, 0 ≤ ai ≤9999
输出For each test case generate a single line containing a single integer that is 1000 times the maximal average value. Do not perform rounding.样例输入
样例输出
来源第八届河南省程序设计大赛上传者
hnu_acm
两个注意点 一个是at least 一个是 Do not perform rounding.
题目信息
运行结果
本题排行
讨论区
Interference Signal
时间限制:2000 ms | 内存限制:65535 KB难度:1
描述
Dr.Kong’s laboratory monitor some interference signals. The interference signals can be digitized into a series of positive integer. May be, there are
N integers a1,a2,…,an.
Dr.Kong wants to know the
average strength of a contiguous interference signal block.
the block must contain at least M integers.
Please help Dr.Kong to calculate the
maximum average strength, given the constraint.
输入The input contains K test cases. Each test case specifies:
* Line 1: Two space-separated integers, N and M.
* Lines2~line N+1: ai (i=1,2,…,N)
1 ≤ K≤ 8, 5 ≤ N≤ 2000, 1 ≤ M ≤ N, 0 ≤ ai ≤9999
输出For each test case generate a single line containing a single integer that is 1000 times the maximal average value. Do not perform rounding.样例输入
2 10 66 42103859415 210385 9
样例输出
65007333
来源第八届河南省程序设计大赛上传者
hnu_acm
两个注意点 一个是at least 一个是 Do not perform rounding.
#include <stdio.h> #include <string.h> int main() { int ncase,a[2005]; scanf("%d",&ncase); while(ncase--) { int n,m; double sum,max=-0x3fffffff; memset(a,0,sizeof(a)); scanf("%d %d",&n,&m); for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=0;i+m<=n;i++) { for(int k=m;k<=n&&i+k<=n;k++) { sum=0; for(int j=0;j<k;j++) sum+=a[i+j]; if(sum/k>max) max=sum/k; } } printf("%d\n",(int)(max*1000)); } return 0; }
相关文章推荐
- 一个简单的Extjs继承实现
- javaScript的原型链
- 三星SOC的显示控制器及framebuffer驱动s3c-fb.c中probe函数分析
- Django1.7+JQuery+Ajax集成小例子
- 那些年用过的一些前端框架
- 那些年用过的一些前端框架
- 那些年用过的一些前端框架
- 那些年用过的一些前端框架
- js020-JSON
- js017-错误处理与调试
- 通过Manifest的配置信息实现页面跳转,及总结
- Javascript常见知识点
- 前端实战(一)-----用ps把PSD切成HTML能用的图片
- 前端实战(一)-----用ps把PSD切成HTML能用的图片
- css hack
- js event 事件兼容浏览器 ie不需要 event参数 firefox 需要
- JavaScript中的对象(一)——对象的创建
- jQuery之event
- css positioning计算和jquery对应函数
- web前端知识结构图