#include<bits/stdc++.h>
#define newl cout<<"\n"
long long dp[100000000];
long long fact(int n)
{
if(n==0)return 1;
if(n==1)return 1;
if(dp[n]!=0)return dp[n];
else{
dp[n]=n*fact(n-1);
return dp[n];
}
}
using namespace std;
int main()
{
int n;
memset(dp,0,sizeof(dp));
while(cin>>n){
// cout<<fact(n)<<" ";
if(n>=14 || (n<0 && n%2!=0))cout<<"Overflow!";
else if(n>=0 && n<=7 ||(n<0 && n%2==0))cout<<"Underflow!";
else cout<<fact(n);
newl;
}
return 0;
}
#define newl cout<<"\n"
long long dp[100000000];
long long fact(int n)
{
if(n==0)return 1;
if(n==1)return 1;
if(dp[n]!=0)return dp[n];
else{
dp[n]=n*fact(n-1);
return dp[n];
}
}
using namespace std;
int main()
{
int n;
memset(dp,0,sizeof(dp));
while(cin>>n){
// cout<<fact(n)<<" ";
if(n>=14 || (n<0 && n%2!=0))cout<<"Overflow!";
else if(n>=0 && n<=7 ||(n<0 && n%2==0))cout<<"Underflow!";
else cout<<fact(n);
newl;
}
return 0;
}
No comments:
Post a Comment