Solution of URI 1161::Factorial Sum
Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problem, you will inform me by comment.
#include <bits/stdc++.h>
using namespace std;
int main(){
int M,N,i;
long long Mfact,Nfact;
while(cin>>M>>N){
Mfact=1,Nfact=1;
for(i=2;i<=M;i++){
Mfact *=i;
}
for(i=2;i<=N;i++){
Nfact *=i;
}
cout<<Mfact+Nfact<<endl;
}
return 0;
}
No comments