提交记录 21747


用户 题目 状态 得分 用时 内存 语言 代码长度
CTZss 1002i. 【模板题】多项式乘法 Wrong Answer 0 26.788 ms 6696 KB C++ 1.76 KB
提交时间 评测时间
2024-05-10 09:18:07 2024-05-10 09:18:12
#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 = 400007;
const double Pi = acos(-1);
int n, m1, m2;
Type f[N]; int rp[N];

void fft(int c)
{
    int i, j, k;
    for (i = 0; i < n; ++i)
        if (i < rp[i])
            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 / 2; ++k, w = w * tg)
            {
                Type t1 = f[k], t2 = f[k + i / 2] * w;
                f[k] = t1 + t2, f[k + i / 2] = t1 - t2;
            }
        }
    }
}

void read(int &x)
{
    char c;
    x = 0;
    do
        c = getchar();
    while (!isdigit(c));
    while (isdigit(c))
        x = x * 10 + c - '0', c = getchar();
}

int st[37];

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;
    n = 1;
    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 #143.22 us48 KBAcceptedScore: 100

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

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

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

Subtask #1 Testcase #537.19 us48 KBAcceptedScore: 0

Subtask #1 Testcase #636.92 us48 KBWrong AnswerScore: 0

Subtask #1 Testcase #735.99 us48 KBAcceptedScore: 0

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

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

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

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

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

Subtask #1 Testcase #1336.05 us44 KBAcceptedScore: 0


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