Problem G: G. Interference Signal

本文介绍了一种计算连续干扰信号块最大平均强度的方法,信号由一系列正整数表示,需包含至少M个整数。通过递归算法找到满足条件的最大平均强度,并提供了完整的C++实现代码。

Problem G: G. Interference Signal

Time Limit: 2 Sec   Memory Limit: 128 MB
Submit: 17   Solved: 16
[ Submit][ Status][ Web Board]

Description


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.

 

Input

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

     

Output

For each test case generate a single line containing a single integer that is 1000 times the maximal average value. Do not perform rounding.

 

Sample Input

2
10 6
6
4
2
10
3
8
5
9
4
1
5 2
10
3
8
5
9

Sample Output

6500
7333

代码如下:

#include<iostream>
#include<stdio.h>
using namespace std;
double A[2000], mk;
int N, M;
void FindmkAver(double sum, int x,int num)
{
    if (x == N)return;
 
    if (num >= M )
        if (((A[x] + sum)/ num) > mk)
            mk = (A[x] + sum) / num;
 
    FindmkAver(sum + A[x], x + 1, num + 1);
    FindmkAver(0, x + 1, 1);
}
int main()
{
    int K;
    cin >> K;
    while (K--)
    {
        mk = 0;
        cin >> N >> M;
        for (int i = 0; i < N; i++)
            cin >> A[i];
 
        for (int j = 0; j < N; j++)
            FindmkAver(0, j, 1);
 
        printf("%.f\n", mk*1000);
    }
    return 0;
}

The overall architecture of the wireless semantic communications system is shown in Fig. 1. At the transmitter, a joint source-channel coding (JSCC) encodes the source image s ∈ R3×Hs×Ws into a semantic feature vector x ∈ R2k, which is then transformed into a complex-valued vextor xc ∈ Ck with normalized power by combining the preamble segment as the real part and the postamble segment as the imaginary part. The signal xc is then transmitted through the wireless channel. Here k represents the number of channel uses for transmiting xc, and Hs and Ws denote the height and width of the source image, respectively. In this paper, we consider the additive white Gaussian noise (AWGN) channel and the Rayleigh fading channel. Specifically, there exists an unknown additive interference zc in the wireless channel. Without loss of generality, we consider that zc has the same dimension as xc and continuously affectsthe reception of xc. Therefore, for i = 1, 2, · · · , k, the i-th element of the received signal yc is given by yc,i = p Pxhx,i xc,i + p Pzhz,i zc,i + nc,i, (1) where Px and Pz are the transmit power of the desired signal and the interference, respectively. Under the Rayleigh fading channel, the gains hx,i and hz,i are independent and identically distributed (i.i.d) as CN(0, 1), while both gains are unity under the AWGN channel. nc,i ∼ CN(0, σ2) are i.i.d AWGN sample. The received signal yc is then equalized and represented as a real vector y ∈ R2k. We consider that the receiver knows the channel state hx = [hx,1, hx,2, · · ·, hx,k] but not hz = [hz,1, hz,2, · · ·, hz,k]. Therefore, in this paper, we apply the classic minimum mean square error (MMSE) equalizer under the Rayleigh fading channel. After equalization, ICDM is applied to y to cancel the interference, and the resulting signal is fed into the JSCC decoder for reconstruction as ˆs. B. Theorem for Interference Cancellation We formulate the interference cancellation task as a MAP estimation problem. Specifically, we seek estimates ˆx, ˆz that maximize the posterior probability of x and z given the observations and known channel state, i.e., (ˆx,ˆz) = arg max x,z log px,z|y,hx (x, z|y, hx), (2) where z =  Re(hzzc) Im(hzzc)  . To illustrate the effectiveness of the formulation, we first clarify their real-valued relationship.Lemma 1. The real-valued vectors x, y and z satisfy y = p PxWxx + p PzWzz +Wnn, (3) where n ∼ N(0, σ2 2 I2k). For the Rayleigh fading channel with MMSE equalizer, H = diag(  |hx| |hx|  ), Hr x = diag(Re(hx)), HI x = diag(Im(hx)), Wz =  Hr x,HI x −HI x,Hr x  (H2 + σ2I)−1, Ws = H2(H2 + σ2I)−1, and Wn = H(H2 + σ2I)−1. For the AWGN channel, Ws =Wz =Wn = I2k. Proof. For the Rayleigh fading channel with MMSE equalization, the i-th symbol of the equalized signal yeq,i is yeq,i = hH x,i |hx,i|2 + σ2 yc,i = √ PxhH x,ihx,i |hx,i|2 + σ2 xc,i + √ PzhH x,ihz,i |hx,i|2 + σ2 zc,i + hH x,i |hx,i|2 + σ2 nc,i. (4) The coefficient hH x,ihx,i |hx,i|2+σ2 = |hx,i|2 |hx,i|2+σ2 is a real and hence extends directly to the full vector x, yielding the matrix Ws. For the second term, both hz,i and zc,i are unknown, so we group them into the vector z and express the product hH x,ihz,izc,i in block-matrix form. This expression then extends naturally to the full vector z, yielding the matrixWz. The third term contains the Gaussian noise sample nc,i. By applying the resampling trick, in which the hH x,inc,i is equivalent to |hx,i|nc,i, we obtain the matrix WnFor the AWGN channel, the equalized signal coincides exactly with the received signal, thus we can easily derive the expression. Lemma 1 illustrates the structure of z in (2). By combining the unknown channel gains hz into the interference signal zc, the coefficient matrices Wx, Wz and Wn depend only on the known gains hx, thereby eliminating all unknown multiplication factors. Therefore, the problem reduces to one of additive interference. We then introduce two assumptions for theoretical analysis. Assumption 1. The transmitted signal x and the interference z are independent. Assumption 2. The functions log px(x) and log pz(z) are each locally strongly convex, with convexity parameters μ > 0 and ν > 0, respectively. Moreover, the ground truth x∗ and z∗, which satisfy y = √ PxWxx∗ + √ PzWzz∗ +Wnn, are local optimums of px(x), pz(z). 不太理解这些
最新发布
09-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值