-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10212.cpp
150 lines (103 loc) · 1.59 KB
/
10212.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using namespace std;
#include<iostream>
long long int calc(long long int u,long long int l)
{
long long int i,pro=1;
for(i=u;i>=l+1;i--)
{
pro=pro*i;
while(pro%10==0)
pro=pro/10;
pro=pro%1000000000;
}
return pro%10;
}
int main()
{
long long int a,b;
while(cin>>a>>b)
{
if(b==0)
cout<<1<<endl;
else
cout<<calc(a,a-b)<<endl;
}
return 0;
}
/*#include <stdio.h>
#define P 20000000
typedef unsigned long long U;
U D[P+1000];
char a[P+1000];
char x[10][10];
void set()
{
x[1][1]=1;
x[1][3]=7;
x[1][7]=3;
x[1][9]=9;
x[3][1]=3;
x[3][3]=1;
x[3][7]=9;
x[3][9]=7;
x[7][1]=7;
x[7][3]=9;
x[7][7]=1;
x[7][9]=3;
x[9][1]=9;
x[9][3]=3;
x[9][7]=7;
x[9][9]=1;
}
void R ()
{
U i,r;
long long count;
a[1]=1;
D[1]=0;
for(i=2; i<P+10; i++)
{
r=i;
count=0;
while(r%2==0)
{
r/=2;
count++;
}
while(r%5==0)
{
r/=5;
count--;
}
r%=10;
a[i] = (r*a[i-1])%10;
D[i] = D[i-1]+count;
}
}
U X(U n, U r)
{
U rem, dig, b[]={2,4,8,6};
if(n==0)
n=1;
if(r==0)
r=1;
rem = D[n]-D[r];
dig = x[a[n]][a[r]];
rem%=4;
if(rem==0)
rem =4;
rem=b[rem-1];
dig*=rem;
return dig%10;
}
int main()
{
U n,r;
R();
set();
while(scanf("%llu %llu",&n,&r)==2)
{
printf("%llu\n",X(n,n-r));
}
return 0;
}*/