-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathfctrl2.cpp
More file actions
71 lines (59 loc) · 1.23 KB
/
fctrl2.cpp
File metadata and controls
71 lines (59 loc) · 1.23 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define inf 1000000000
using namespace std;
vector<int> factoriel[100];
void izracunaj_faktorijele()
{
int tmp = 0;
int a[200] = {1};
int m = 1;
for (int i = 1; i <= 100; ++i)
{
for (int j = 0; j < m; ++j)
{
tmp = a[j] * i + tmp;
a[j] = tmp % 10;
tmp /= 10;
factoriel[i-1].push_back(a[j]);
}
while (tmp > 0)
{
a[m] = tmp % 10;
tmp /= 10;
factoriel[i-1].push_back(a[m++]);
}
}
}
int main()
{
cin.sync_with_stdio(false);
int t;
cin >> t;
izracunaj_faktorijele();
for (int qwertz = 0; qwertz < t; ++qwertz)
{
int n;
cin >> n;
--n;
for (vector<int>::reverse_iterator it = factoriel[n].rbegin(); it != factoriel[n].rend(); ++it)
{
cout << *it;
}
cout << "" << endl;
}
return 0;
}