library_checker/math/
sqrt_of_formal_power_series.rs1use competitive::prelude::*;
2#[doc(no_inline)]
3pub use competitive::{math::Fps998244353, num::montgomery::MInt998244353};
4
5#[verify::library_checker("sqrt_of_formal_power_series")]
6pub fn sqrt_of_formal_power_series(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, a: [MInt998244353; n]);
10 let f = Fps998244353::from_vec(a);
11 if let Some(g) = f.sqrt(n) {
12 iter_print!(writer, @it g.data);
13 } else {
14 iter_print!(writer, "-1");
15 }
16}