-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1057.cpp
More file actions
52 lines (48 loc) · 914 Bytes
/
Copy path1057.cpp
File metadata and controls
52 lines (48 loc) · 914 Bytes
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
/*************************************************************************
> File Name: 1057.cpp
> Author: dulun
> Mail: dulun@xiyoulinux.org
> Created Time: 2016年04月01日 星期五 18时03分45秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
#define mod 100000000000000;
const int N = 1000086;
LL a[N];
int main()
{
int n;
while(~scanf("%d", &n))
{
memset(a, 0, sizeof(a));
LL l = 0;
a[0] = 1;
for(int i = 1; i <= n; i++)
{
LL c = 0;
for(int j = 0; j <= l; j++)
{
LL t = a[j] * i + c;
a[j] = t % mod;
c = t / mod;
}
if(c != 0)
{
l++;
a[l] = c;
}
}
printf("%lld", a[l]);
for(int i = l-1; i >= 0; i--)
{
printf("%014lld\n", a[i]);
}
}
return 0;
}