library_checker/polynomial/
sqrt_of_formal_power_series_sparse.rs

1use competitive::prelude::*;
2#[doc(no_inline)]
3pub use competitive::{math::Fps998244353, num::Zero as _, num::montgomery::MInt998244353};
4
5#[verify::library_checker("sqrt_of_formal_power_series_sparse")]
6pub fn sqrt_of_formal_power_series_sparse(reader: impl Read, mut writer: impl Write) {
7    let s = read_all_unchecked(reader);
8    let mut scanner = Scanner::new(&s);
9    scan!(scanner, n, k);
10    let mut a = vec![MInt998244353::zero(); n];
11    for _ in 0..k {
12        scan!(scanner, i, a_i: MInt998244353);
13        a[i] = a_i;
14    }
15    let f = Fps998244353::from_vec(a);
16    if let Some(g) = f.sqrt(n) {
17        iter_print!(writer, @it g.data);
18    } else {
19        iter_print!(writer, "-1");
20    }
21}