示例#1
0
    static object Solve()
    {
        var(R, G, B, K) = Read4();
        var(X, Y, Z)    = Read3();

        var mc = new MCombination(R + G + B);
        var rs = new long[R + 1];
        var gs = new long[G + 1];
        var bs = new long[B + 1];

        for (int r = K - Y; r <= R; r++)
        {
            rs[r] = mc.MNcr(R, r);
        }
        for (int g = K - Z; g <= G; g++)
        {
            gs[g] = mc.MNcr(G, g);
        }
        for (int b = K - X; b <= B; b++)
        {
            bs[b] = mc.MNcr(B, b);
        }

        rs = FNTT.Convolution(rs, gs);
        rs = FNTT.Convolution(rs, bs);
        return(rs[K]);
    }
示例#2
0
    static void Main()
    {
        Console.ReadLine();
        var a = ReadL();
        var b = ReadL();

        var c = FNTT.Convolution(a, b);

        Console.WriteLine(string.Join(" ", c));
    }
示例#3
0
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = new long[n + 1];
        var b = new long[n + 1];

        for (int i = 1; i <= n; i++)
        {
            var v = Read();
            a[i] = v[0];
            b[i] = v[1];
        }

        var ab = FNTT.Convolution(a, b);

        Console.WriteLine(string.Join("\n", ab[1..]));
示例#4
0
    static void Main()
    {
        var h = Console.ReadLine().Split();

        char[] sa = h[0].ToCharArray(), sb = h[1].ToCharArray();

        var neg_a  = sa[0] == '-';
        var neg_b  = sb[0] == '-';
        var neg_ab = neg_a ^ neg_b;

        var a = Array.ConvertAll(sa, c => (long)(c - '0'));
        var b = Array.ConvertAll(sb, c => (long)(c - '0'));

        Array.Reverse(a);
        Array.Reverse(b);
        if (neg_a)
        {
            Array.Resize(ref a, a.Length - 1);
        }
        if (neg_b)
        {
            Array.Resize(ref b, b.Length - 1);
        }

        var ab = FNTT.Convolution(a, b);

        for (int i = 0; i < ab.Length - 1; i++)
        {
            if (ab[i] < 10)
            {
                continue;
            }
            ab[i + 1] += ab[i] / 10;
            ab[i]     %= 10;
        }

        Console.WriteLine(ToString(ab, neg_ab));
    }