This is a relatively simple simulation, because the operation rules have been told to us, and relatively simple, do not be frightened ...
Idea: The polynomial divided by another polynomial, if it can be removed, then his highest time must be lowered, if the highest times can not be reduced, that the explanation has been unable to be removed, that is, the title of the film is required to output, the method of reducing the highest times is very simple, as long as the highest number of >= except the highest times, The top of the formula is raised to the same height as the removed type, and then subtracted from it until the above relationship is not satisfied.
The code is as follows:
#include <cstdio>#include<algorithm>#include<iostream>#include<cstring>using namespacestd;#defineMAXN 1100intF[MAXN],G[MAXN],H[MAXN];intmul[maxn*2],now[maxn*2];intMain () {intt,f1,g1,h1,m1,tmp; scanf ("%d",&t); while(t--) {scanf ("%d",&F1); for(inti = f1-1; I >=0; i--) scanf ("%d",&F[i]); scanf ("%d",&G1); for(inti = g1-1; I >=0; i--) scanf ("%d",&G[i]); scanf ("%d",&H1); for(inti = h1-1; I >=0; i--) scanf ("%d",&H[i]); for(inti =0; I <= f1+g1;i++) mul[i] =0; for(inti =0; I < f1;i++){ for(intj =0; J < g1;j++) {Mul[i+J] + = f[i]*G[j]; Mul[i+J]%=2; }} H1--; M1= f1+g1-2; while(H1 <=M1) {tmp= M1-H1; for(inti =0; I <= m1;i++) now[i] =0; for(inti =0; I <= h1;i++) {Now[i+TMP] =H[i]; } for(inti = M1;i >=0; i--) Mul[i] = (mul[i]+now[i])%2; for(inti = M1;i >=0; i--) { if(Mul[i]) {M1=i; Break; }}} printf ("%d", m1+1); for(inti = M1;i >=0; i--) {printf ("%d", Mul[i]); } puts (""); } return 0;}
Uvalive 2323Modular multiplication of polynomials (analog)