} int Fabricate(int m,int n) { int sum_m=1,sum_n=1,sum_mn,sum; int i=m,j=n; for(int i=m;i>0;i--)//求m的阶乘 sum_m*=i; for(int j=0;j>0;j--)//求n的阶乘 sum_n*=j; sum_mn=multi(m,n); return (sum_m/sum_n)*sum_mn;
} int multi(int m,int n) { int sum=1; int k=m-n; while(k>0) sum*=k--; return sum; }
薄荷绿℡
2024-06-09 09:21:56
#include<iostream> using namespace std; int main() { int m,n; int Fabricate(int m, int n); while(cin>>m>>n) cout<<Fabricate(m,n)<<endl; return 0; }
int Fabricate(int m, int n) { int Multi(int m, int n); cout<<Multi(m,n)<<endl; if(n>m-n) return Multi(m,n+1)/Multi(m-n,1); else return Multi(m,m-n+1)/Multi(n,1); } int Multi(int m,int n) { if(m<n) return 1; if(m==n) return n; return m*Multi(m-1,n); }