pub fn build_subsum_tree<T>(a: Vec<T>) -> Vec<T> where
    T: Sized + Clone + Zero,
    for<'x> &'x T: Add<Output = T>, 
Expand description

calc subsum tree

  14
  /\
 5  9
/\  /\
2 3 4 5
use ring_algorithm::build_subsum_tree;
let a = vec![2, 3, 4, 5];
let b = vec![14, 5, 9, 2, 3, 4, 5];
let r = build_subsum_tree(a);
assert_eq!(b, r);
let a = vec![2, 3, 4, 5, 6];
let b = vec![20, 14, 6, 5, 9, 6, 0, 2, 3, 4, 5, 6, 0, 0, 0];
let r = build_subsum_tree(a);
assert_eq!(b, r);