Interference Signal 第八届
生活随笔
收集整理的這篇文章主要介紹了
Interference Signal 第八届
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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.
輸入* 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
AC代碼:
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; int main() {int M,N,K;int a[2010];int i,j,k;double sum,s;while(cin>>K)while(K--){cin>>N>>M;for(i=0;i<N;i++)scanf("%d",&a[i]);s=0;for(i=0;i+M<=N;i++)//控制開始位置{for(k=M;i+k<=N;k++)//求和區間{sum=0.0;for(j=0;j<k;j++)sum+=a[i+j];s=max(sum/k,s);}}printf("%d\n",(int)(s*1000));} }總結
以上是生活随笔為你收集整理的Interference Signal 第八届的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 实战-Ueditor扩展二次开发
- 下一篇: 引水工程(第八届)