题目:
代码:
class Solution {
public:
int gcd(int a,int b){
if(a*b==0) return a+b;
else if(a>=b) return gcd(b,a%b);
else return gcd(a,b%a);
}
vector<int> getRow(int rowIndex) {
vector<int> ans(rowIndex+1);
ans[0]=1;
int x;
for(int i=1;i<=rowIndex;i++){
x=gcd(rowIndex-i+1,i);
ans[i]=ans[i-1]/(i/x);
ans[i]*=((rowIndex-i+1)/x);
}
return ans;
}
};