use std::inner_product and std::partial_sum