POJ1060 Modular multiplication of polynomials

题目来源:http://poj.org/problem?id=1060

题目大意:

  考虑系数为0和1的多项式。两个多项式的加法可以通过把相应次数项的系数相加而实现。但此处我们用模2加法来计算系数之和。一个实例:

(x^6 + x^4 + x^2 + x + 1) + (x^7 + x + 1) = x^7 + x^6 + x^4 + x^2

同样,多项式的减法我们在求系数之差时也用模2减法,例如:

(x^6 + x^4 + x^2 + x + 1) - (x^7 + x + 1) = x^7 + x^6 + x^4 + x^2 

 

多项式的乘法与平常的做法一致,但同次项系数相加时使用模二加法,例如:

(x^6 + x^4 + x^2 + x + 1) (x^7 + x + 1) = x^13 + x^11 + x^9 + x^8 + x^6 + x^5 + x^4 + x^3 + 1 

两个多项式f(x)和g(x)模多项式h(x)是求f(x)*g(x)除以h(x)的余数。例如:

(x^6 + x^4 + x^2 + x + 1) (x^7 + x + 1) modulo (x^8 + x^4 + x^3 + x + 1) = x^7 + x^6 + 1 

 

多项式中最高次数称为degree。给出f(x) g(x)和h(x),写一个程序求出  f(x)*g(x) mod h(x)  的结果。假定f(x)和g(x)的degree都小于h(x),多项式的degree都小于1000。

由于系数都是0或1,假设多项式的degree为d,那么该多项式可以由一个次数指示整数(d + 1)和d+1个二进制位来表示。比如x^7 + x^6 + 1 可表示为: 8 1 1 0 0 0 0 0 1.

输入:由T个测试用例组成,并在输入的第一行给出T的值。每个用例由三行组成,分别为f(x),g(x),h(x)。多项式的表示方法如前所述。

输出:用如前所述的表示方式表达f(x)*g(x)%h(x)的值。每行对应一个输出的多项式。


Sample Input

2 
7 1 0 1 0 1 1 1 
8 1 0 0 0 0 0 1 1 
9 1 0 0 0 1 1 0 1 1 
10 1 1 0 1 0 0 1 0 0 1 
12 1 1 0 1 0 0 1 1 0 0 1 0 
15 1 0 1 0 1 1 0 1 1 1 1 1 0 0 1

Sample Output

8 1 1 0 0 0 0 0 1 
14 1 1 0 1 1 0 0 1 1 1 0 1 0 0

 模拟题, 需要注意的两个地方:

1. 虽然题目中涉及的f(x) g(x) h(x)和输出的结果r(x)最高次都不会超过1000, 但中间结果f(x) * g(x)的最高次可能会超过1000,最大到2000.

2. 余数为0情况应输出0 0.

第一次用bitset.

 1 ////
 2 //        POJ1060 Modular multiplication of polynomials
 3 //        Memory: 224K        Time: 63MS
 4 //        Language: C++        Result : Accepted
 5 ///
 6 
 7 #include 
 8 #include 
 9 
10 using namespace std;
11 
12 bitset<1001> fx;
13 bitset<1001> gx;
14 bitset<1001> hx;
15 bitset<2002> rx;
16 int dfx, dgx, dhx, drx;
17 
18 int main(void) {
19     int T;
20     cin >> T;
21     for (int case_id = 0; case_id < T; ++case_id) {
22         
23         fx.reset();
24         gx.reset();
25         hx.reset();
26         rx.reset();
27         
28         //读取输入
29         cin >> dfx;
30         int buf;
31         for (int d = dfx - 1; d >= 0; --d) {
32             cin >> buf;
33             fx[d] = buf;
34         }
35         cin >> dgx;
36         for (int d = dgx - 1; d >= 0; --d) {
37             cin >> buf;
38             gx[d] = buf;
39         }
40         cin >> dhx;
41         for (int d = dhx - 1; d >= 0; --d) {
42             cin >> buf;
43             hx[d] = buf;
44         }
45         
46         //乘法计算
47         for (int d1 = dfx - 1; d1 >= 0; --d1) {
48             for (int d2 = dgx - 1; d2 >= 0; --d2) {
49                 rx[d1 + d2] = fx[d1] & gx[d2] ^ rx[d1 + d2];
50             }
51         }
52         for (drx = 2001; drx >= 0; --drx) {
53             if (rx[drx] == 1) {
54                 ++drx;
55                 break;
56             }
57         }
58 
59         //除法计算
60         while (drx >= dhx && drx > 0) {
61             int t = drx - dhx;
62             for (int d = dhx - 1; d >= 0; --d) {
63                 rx[d + t] = hx[d] ^ rx[d + t];
64             }
65             while (drx >= 0 && rx[drx] == 0) {
66                 --drx;
67             }
68             ++drx;
69         }
70 
71         //输出
72         cout << drx;
73         for (int d = drx - 1; d > 0; --d) {
74             cout << " " << rx[d];
75         }
76         cout << " " << rx[0] << endl;
77     }
78     return 0;
79 }
View Code

附测试数据:

10
7 1 0 1 0 1 1 1
8 1 0 0 0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