UOJ443 [Job Training Homework 2018] Unspeakable

Link
setting \ (n = 65536, x = \ omega_n ^ k \) .
The following is the approximate process of using the backstepping method:
\ (1. \) treats the initial sequence as \ (x ^ {\ varnothing} \) , and then FWT gets \ (\ sum \ limits_ {S \ subseteq U} x ^ S \) .
\ (2. \) gets \ (a_i = x ^ i \) for every \ (i \ in [0,16) \) call . \ (3. \) IDFT gets \ (a_i = [i = k] \) . \ (4. \) Use once to get an accurate answer.CU(i,1<<i)

QR

FWT

FWT process for small to large \ (i \ in [0,16) \) do CR(i,i,M), where \ (M = \ pmatrix the begin {}. 1. 1 & & \\. 1 -1 \ pmatrix End {} \) .
In order to guarantee \ (MM ^ * = I \) , modify \ (M \ leftarrow | \ frac1 {| M |} | M \) , which is \ (M = \ begin {pmatrix} \ frac1 {\ sqrt 2} & \ frac1 {\ sqrt 2} \\\ frac1 {\ sqrt 2} &-\ frac1 {\ sqrt 2} \ end {pmatrix} \) .

IDFT

The first is to replace \ (\ omega_n ^ i \)reverse with \ (\ overline {\ omega_n ^ i} \) . If we neglect this operation, then the last call QRreturns \ (nk \) , and it will not affect us to find the answer. Of course, using \ (\ overline {\ omega_n ^ i} \) directly instead of \ (\ omega_n ^ i \) is no problem.
Then bitreverse, just to the first \ (2 \) steps in CU(i,1<<i)to change CU(i,1<<(15-i))to achieve the same effect.
Followed by a DFT process, from small to large enumeration \ (I \ in [0,16) \) , then first of all to meet the (2 ^ i \ subseteq S \ ) \ for \ (a_S = a_S \ omega_ { 2 ^ { i + 1}} ^ S \) operation, then call again CR(i,i,M).
The first operation may \ (j \ in [0, i) \) do CR(i,j,N), where \ (N = \ begin {pmatrix } 1 & 0 \\ 0 & \ omega_ {2 ^ {i + 1}} ^ {2 ^ j } \ end {pmatrix} \) .
Obviously \ (NN ^ * = I \), Analysis found that doing so can complete the required modification without modifying other elements.
Finally, each position is divided by \ (\ frac1n \) , and we still ignore the operation, which does not have a substantial impact.

Tips

In FWT and IDFT, the \ (M \) matrix we use is multiplied by a coefficient of \ (\ frac1 {\ sqrt2} \) relative to the correct \ (M \) matrix . Therefore, after FWT and IDFT, the result we get is \ (\ frac1 {\ sqrt n} \) times the correct result . In this way, the effect of the last step of IDFT can be achieved. And it is not difficult to find that, while keeping the relative size unchanged, multiplying the whole number of \ (a \) sequence by one number will not affect the result.


QR

#include<cmath>
#include<numeric>
#include"unnamable.h"
using cp=std::complex<double>;
const int N=65536;const double pi=acos(-1),s2=sqrt(0.5);
cp omega(int k){return cp(cos(2*pi*k/N),sin(2*pi*k/N));}
cp FWT[2][2]={{s2,s2},{s2,-s2}},FFT[2][2]={{1,0},{0,0}};
cp SOL(int t)
{
    INI(16);
    for(int i=0;i<16;++i) CR(i,i,FWT);
    for(int i=0;i<16;++i) CU(i,1<<(15-i));
    for(int i=0;i<16;CR(i,i,FWT),++i) for(int j=0;j<i;++j) FFT[1][1]=omega(1<<(15-i+j)),CR(i,j,FFT);
    return omega(-QR());
}

Guess you like

Origin www.cnblogs.com/cjoierShiina-Mashiro/p/12722354.html