题解 | #乳牛各类产奶统计#
乳牛各类产奶统计
https://www.nowcoder.com/practice/4e4c1e24208e44a8a9b8c7dd5f829017
#include<bits/stdc++.h> #include <vector> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param milk_amount int整型vector * @return int整型vector */ vector<int> product_except_self(vector<int>& milk_amount) { // write code here int len = milk_amount.size(); vector<int> ans(len,0); for(int i=0; i<len; ++i) ans[i] = accumulate(milk_amount.begin() ,milk_amount.begin()+i ,1 ,multiplies<int>()) * accumulate(milk_amount.begin()+i+1,milk_amount.end() ,1 ,multiplies<int>( )); return ans; } };
虚数五行区解题中心 文章被收录于专栏
非淡泊无以明志,非宁静无以致远