leetcode - 62. Unique Paths

在这里插入图片描述

class Solution {
public:
    int uniquePaths(int m, int n) {
        long long ret(1);
        int i(0);
        if(m<n) swap(m,n);
        --n;
        for(m;i<n;++i,++m)
        {
            ret*=m;
        }
        while(n>1)
        {
            ret/=n--;
        }
        return (int)ret;
    }
};

猜你喜欢

转载自blog.csdn.net/weixin_41938758/article/details/89075508