要让这个三角形合法,只需满足三角形不等式 即$a+b>c$,设$c=max\left\{a,b,c\right\}$,上式转化为$c<a+b$ 如果已经满足,不需消耗代价 否则消耗$c-a-b+1$的代价 #include<iostream> #include<cstdio> using namespace std; int a,b,c,maxn; int main() { scanf("%d%d%d",&a,&b,&c);…
题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 代码: class Solution { public: vector<vector<int>> generate(int numRows) { vector<vector…
题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 代码:oj测试通过 Runtime: 46 ms class Solution: # @return a list of lists of integers def generate(self…