• sdibt 2128Problem A:Convolution Codes


    Description

    Channel is a very important part of a digital communication system.The characteristics of the channel affect the performance of the whole digital communication system.The noise and interference in the real channel make the codes received different from the codes sent.The difference is generally called error.In order to improve the quality of communication and ensure the reliability and validity of communication, error-control coding is usually adopted to correct the errors produced in the process of transfer before the digital signals enter the channel. 
      Error-control coding is all effective method to enhance the communication quality by adding redundant information into the original message. Convolution code is a kind of error-correcting code which is used very widely. So,as the corresponding best decode method of the convolution codes,Viterbi decoder is always researched widely. 
      Now, we only want to do some research about the encoding of convolution codes. First we give an example to you to explain the procedure of the encoding: 
       If we research the encoding of the (2,1,7) convolution codes. And the rate of the convolution codes is 1/2, the construction is the following picture: 


       The connection parameter is 1011011 and 1111001. So we can define the generation matrix P: 

    So: 

       As we all know, the convolution operation (‘U’) is defined as follows: 

    For the discrete convolution, 

      We can know : length(Z) = length(X))+ length(Y) - 1; 
      In this problem we use the binary discrete convolution. When we calculate Z (n) = X (n) U Y(n),We should also do it like this :
      First, do the discrete convolution, then for all the Z(i), Z(i) = Z(i) % 2;
      If we give an input A=[1 1 1 0 1 1 1 0 1 1], we need to calculate the output sequence after encoding. As above, the generation matrix has told to you, so We can calculate the answer as follows:
    B = AUP(1);
    C = AUP(2);
      Then for every B(i) and C(i), you just need do like this 
    B(i) = B(i) % 2=[1100110001100101]; 
    C(i) = C(i) % 2=[1011110001110011];
    The encoding output is [B(1)C(1)B(2)C(2) ……];
      In this problem, the generation matrix is unique which is told above, we will give you the input sequence, you will tell us the sequence after encoding.
    Pay attention to that all the input and output is 0 or 1 sequence.

    Input

    There are plenty of test cases,for each test case : There is a sequence which contains a series of ‘0’ and ‘1’ in one line. The length of the input sequence is at most 1000 and at least 1. The end of the input is indicated by the end of the file(EOF).

    Output

    For each test case , you should output the test case number and the sequence after convolution encoding in a line. The format is like the sample.

    Sample Input

    1110111011
    0100111
    111011000
    1111
    01100
    110101

    Sample Output

    Case 1: 11100101111100000011110100100111
    Case 2: 00110111001011100001010111
    Case 3: 111001011111110100100111000000
    Case 4: 11100110011010010111
    Case 5: 0011101000111001110000
    Case 6: 111010111010110001111011

    比赛的时候被题目吓到了,一直没有看,最后看其他题目都是自己不太熟悉的算法才看这题- -发现,原来前面一堆都是没用的废话,
    题意就是已知两个变换矩阵p0,p1,现在告诉你一个矩阵A,让你根据要求的变换方式进行变换。。直接模拟就行- -
    View Code
     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <algorithm>
     5 using namespace std;
     6 const int N=1010;
     7 int main()
     8 {
     9     char p1[8]={"1011011"};
    10     char p2[8]={"1111001"};
    11     char a[N],b[N*2],c[N*2];
    12     int i,j,cas=1;
    13     while(scanf("%s",a)!=EOF)
    14     {
    15         printf("Case %d: ",cas++);
    16         memset(b,0,sizeof(b));
    17         memset(c,0,sizeof(c));
    18         for(i=0;a[i];i++)
    19             for(j=0;j<7;j++)
    20             {
    21                 b[i+j]+=(a[i]-'0')*(p1[j]-'0');
    22                 c[i+j]+=(a[i]-'0')*(p2[j]-'0');
    23             }
    24         int len=strlen(a)+7-1;
    25         for(i=0;i<len*2;i++)
    26         {
    27             if(i%2==0)
    28                 printf("%c",b[i/2]%2+'0');
    29             else
    30                 printf("%c",c[i/2]%2+'0');
    31         }
    32         printf("\n");
    33     }
    34     return 0;
    35 }
  • 相关阅读:
    算法:记忆化搜索算法
    Ubuntu:命令行下浏览网页
    python:socket网络编程
    ACM:读入优化
    使用JDBC连接操作数据库
    Function题解
    csps模拟测试50反思
    模拟测试49
    阶段总结20190919
    NOIP模拟测试36考试反思
  • 原文地址:https://www.cnblogs.com/wilsonjuxta/p/2963774.html
Copyright © 2020-2023  润新知