日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Interference Signal 第八届

發布時間:2025/3/16 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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.

輸入
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 6
6 4210385941
5 2
10385 9
樣例輸出
6500
7333
來源
第八屆河南省程序設計大賽

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 第八届的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。