/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
vector<int> data ,jak;
int n,i,a,j,c,k,p ;
void getFactorial()
{
data.pb(1) ;
for(i=2 ; i<=n ; i++)
{
c =0 ,k =0 ;
for(j=0 ; j<data.size() ; j++)
{
p = data[j]*i + c ;
//t = p%10 ;
jak.pb(p%10) ;
c = p/10 ;
}
while(c!=0)
{
jak.pb(c%10) ;
c/=10 ;
}
data.clear() ;
data = jak ;
jak.clear() ;
}
reverse(data.begin(),data.end()) ;
for(i=0 ; i<data.size() ; i++)
pf("%d",data[i]) ;
pf("\n") ;
data.clear() ;
}
int main()
{
while(sc("%d",&n)==1)
{
if(n<8)
{
if(n<0 && n%2==0)
pf("Underflow!\n") ;
else if(n<0 && n%2!=0)
pf("Overflow!\n") ;
else if(n==0 || n<=7)
pf("Underflow!\n") ;
continue ;
}
if(n>13)
{
pf("Overflow!\n") ;
continue ;
}
getFactorial() ;
}
return 0;
}
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
vector<int> data ,jak;
int n,i,a,j,c,k,p ;
void getFactorial()
{
data.pb(1) ;
for(i=2 ; i<=n ; i++)
{
c =0 ,k =0 ;
for(j=0 ; j<data.size() ; j++)
{
p = data[j]*i + c ;
//t = p%10 ;
jak.pb(p%10) ;
c = p/10 ;
}
while(c!=0)
{
jak.pb(c%10) ;
c/=10 ;
}
data.clear() ;
data = jak ;
jak.clear() ;
}
reverse(data.begin(),data.end()) ;
for(i=0 ; i<data.size() ; i++)
pf("%d",data[i]) ;
pf("\n") ;
data.clear() ;
}
int main()
{
while(sc("%d",&n)==1)
{
if(n<8)
{
if(n<0 && n%2==0)
pf("Underflow!\n") ;
else if(n<0 && n%2!=0)
pf("Overflow!\n") ;
else if(n==0 || n<=7)
pf("Underflow!\n") ;
continue ;
}
if(n>13)
{
pf("Overflow!\n") ;
continue ;
}
getFactorial() ;
}
return 0;
}
No comments:
Post a Comment