1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include <iostream> #include <cstring> #include <algorithm>
using namespace std;
int main() { int n; cin >> n; int res = 1, d2 = 0, d5 = 0; for (int i = 1; i <= n; i ++ ) { int x = i; while (x % 2 == 0) x /= 2, d2 ++ ; while (x % 5 == 0) x /= 5, d5 ++ ; res = res * x % 10; }
for (int i = 0; i < d2 - d5; i ++ ) res = res * 2 % 10; cout << res << endl;
return 0; }
|