提交记录 21746


用户 题目 状态 得分 用时 内存 语言 代码长度
CTZss 1002i. 【模板题】多项式乘法 Wrong Answer 0 26.617 ms 6696 KB C++ 1.82 KB
提交时间 评测时间
2024-05-10 09:17:20 2024-05-10 09:17:24
#include <bits/stdc++.h>
// using namespace std;

struct Type
{
    double a, b;
    Type operator + (const Type &x) const { return (Type){a + x.a, b + x.b}; }
    Type operator - (const Type &x) const { return (Type){a - x.a, b - x.b}; }
    Type operator * (const Type &x) const { return (Type){a * x.a - b * x.b, a * x.b + b * x.a}; }
};

const int N = 300007;
const double Pi = acos(-1);
int n = 1, m1, m2;
Type f[N]; int rp[N];

inline void fft(int c)
{
    int i, j, k;
    for (i = 0; i < n; ++i)
        if (i < rp[i])
            std::swap(f[i], f[rp[i]]);
    for (i = 2; i <= n; i <<= 1)
    {
        Type tg = {cos(Pi * 2 / i), sin(Pi * 2 / i) * c};
        for (j = 0; j < n; j += i)
        {
            Type w{1, 0};
            for (k = j; k < j + (i >> 1); ++k, w = w * tg)
            {
                Type t1 = f[k], t2 = f[k + (i >> 1)] * w;
                f[k] = t1 + t2, f[k + (i >> 1)] = t1 - t2;
            }
        }
    }
}

inline void read(int &x)
{
    char c;
    x = 0;
    do
        c = getchar();
    while (c < '0' || c > '9');
    while (c >= '0' && c <= '9')
        x = (x << 3) + (x << 1) + c - '0', c = getchar();
}

int st[12];

inline void write(long long x)
{
    int tot = 0;
    while (x)
        st[tot++] = x % 10, x /= 10;
    while (tot--)
        putchar(st[tot] + '0');
    putchar(' ');
}

int main()
{
    int i, x, lg = 0;
    scanf("%d%d", &m1, &m2),++m1,++m2;
    for (i = 0; i < m1; ++i)
        read(x), f[i].a = x;
    for (i = 0; i < m2; ++i)
        read(x), f[i].b = x;
    while (n < m1 + m2 - 1)
        n <<= 1, ++lg;
    for (i = 0; i < n; ++i)
        rp[i] = (rp[i >> 1] >> 1) | ((i & 1) << (lg - 1));
    fft(1);
    for (i = 0; i < n; ++i)
        f[i] = f[i] * f[i];
    fft(-1);
    for (i = 0; i < m1 + m2 - 1; ++i)
        write((long long)(round(f[i].b / n) / 2));
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #141.31 us44 KBAcceptedScore: 100

Subtask #1 Testcase #226.287 ms6 MB + 472 KBAcceptedScore: 0

Subtask #1 Testcase #310.869 ms2 MB + 836 KBWrong AnswerScore: -100

Subtask #1 Testcase #410.992 ms2 MB + 824 KBWrong AnswerScore: 0

Subtask #1 Testcase #537.9 us44 KBAcceptedScore: 0

Subtask #1 Testcase #636.57 us44 KBWrong AnswerScore: 0

Subtask #1 Testcase #735.93 us44 KBAcceptedScore: 0

Subtask #1 Testcase #824.981 ms6 MB + 204 KBAcceptedScore: 0

Subtask #1 Testcase #924.938 ms6 MB + 204 KBAcceptedScore: 0

Subtask #1 Testcase #1023.823 ms5 MB + 960 KBAcceptedScore: 0

Subtask #1 Testcase #1126.617 ms6 MB + 552 KBAcceptedScore: 0

Subtask #1 Testcase #1221.01 ms5 MB + 236 KBWrong AnswerScore: 0

Subtask #1 Testcase #1335.69 us44 KBAcceptedScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2025-07-18 10:29:08 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠