mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P1134 [USACO3.2]阶乘问题
R53347070
This commit is contained in:
parent
d89b5a3fc2
commit
d481cadb74
20
Luogu/problem/P1134/P1134.cpp
Normal file
20
Luogu/problem/P1134/P1134.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, ans = 1, a[] = {6, 8, 4, 2};
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
while (n) {
|
||||
for (int i = 1; i <= n % 10; i++) {
|
||||
if (i != 5) {
|
||||
ans = ans * i % 10;
|
||||
}
|
||||
}
|
||||
n = n / 5;
|
||||
ans = ans * a[n % 4] % 10;
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user