-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path24_smallfact.cpp
55 lines (52 loc) · 976 Bytes
/
24_smallfact.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>
#include<vector>
using namespace std;
vector<int> myint;
void displayRev()
{
cout<<"\n";
for(int i=myint.size()-1;i>=0;i--)
{
cout<<myint[i];
}
cout<<"\n";
}
int main()
{
int N,n,temp,x,i;
cin>>N;
while(N--)
{
cin>>n;
myint.clear();
myint.push_back(n%10);
myint.push_back((n/10)%10);
myint.push_back(n/100);
//display();
n--;
while(n)
{
temp=0;
for(i=0;i<myint.size();i++)
{
x=myint[i]*n+temp;
myint[i]=x%10;
temp=x/10;
}
while(temp)
{
myint.push_back(temp%10);
temp/=10;
}
n--;
}
i=myint.size()-1;
while(myint[i]==0)
{
myint.pop_back();
i--;
}
displayRev();
}
return 0;
}