Uvalive 2323Modular multiplication of polynomials (analog)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.