結果

問題 No.2271 平方根の13桁精度近似計算
ユーザー ruthenruthen
提出日時 2023-04-15 01:33:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,961 bytes
コンパイル時間 2,811 ms
コンパイル使用メモリ 203,532 KB
実行使用メモリ 814,208 KB
最終ジャッジ日時 2024-04-18 22:41:31
合計ジャッジ時間 6,440 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 MLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

#include <atcoder/modint>
using mint = atcoder::static_modint<258280327>;
ostream &operator<<(ostream &os, const mint &p) { return os << p.val(); }

V<mint> convolution(V<mint> &a, V<mint> &b) {
    assert(a.size() == b.size());
    const int n = (int)a.size();
    if (n <= 32) {
        V<mint> c(n + n - 1);
        REP(i, n) REP(j, n) c[i + j] += a[i] * b[j];
        return c;
    }
    const int n2 = (n + 1) / 2;
    V<mint> a0(n2), a1(n2), b0(n2), b1(n2);
    for (int i = 0; i < n2; i++) {
        a0[i] = a[i];
        b0[i] = b[i];
    }
    for (int i = n2; i < n; i++) {
        a1[i - n2] = a[i];
        b1[i - n2] = b[i];
    }
    V<mint> a01(n2), b01(n2);
    REP(i, n2) {
        a01[i] = a0[i] + a1[i];
        b01[i] = b0[i] + b1[i];
    }
    auto c0 = convolution(a0, b0);
    auto c1 = convolution(a1, b1);
    auto c2 = convolution(a01, b01);
    V<mint> c(n2 + n2 + n2 + n2 - 1);
    REP(i, n2 + n2 - 1) {
        c[i] += c0[i];
        c[i + n2] += c2[i] - c0[i] - c1[i];
        c[i + n2 + n2] += c1[i];
    }
    return c;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    N++;
    V<mint> A(N);
    REP(i, N) {
        long long a;
        cin >> a;
        A[i] = mint(a);
    }
    int M;
    cin >> M;
    M++;
    V<mint> B(M);
    REP(i, M) {
        long long b;
        cin >> b;
        B[i] = mint(b);
    }
    int K = max(N, M);
    while (A.size() < K) A.push_back(0);
    while (B.size() < K) B.push_back(0);
    auto C = convolution(A, B);
    while (C.size() > 0 and C.back() == 0) C.pop_back();
    if (C.size() == 0) {
        C.push_back(0);
    }
    cout << C.size() - 1 << '\n';
    REP(i, C.size()) cout << C[i] << " \n"[i + 1 == C.size()];
    return 0;
}
0