Logop1134 factorial problem, logop1134 factorial
Description
Maybe you have long known the meaning of factorial. N factorial is generated by multiplying 1 to N, for example:
12! = 1x2x3x4x5x6x7x8x9x10x11x12 = 479,001,600
The rightmost non-zero digit of the factorial of 12 is 6.
Write a program to calculate the value of the non-zero bits on the far right of the N (1 <=n <= 50,000,000) factorial.
Note: 10,000,000! There are 2499999 zeros.
Input/Output Format
Input Format:
Only one row contains a positive integer N.
Output Format:
A single row contains an integer representing the value of the non-zero digit on the rightmost side.
Input and Output sample input sample #1: Copy
12
Output example #1: Copy
6
Description
USACO Training Section 3.2
You cannot understand the solution.
Violence is acceptable.
# Include <cstdio> int main () {long int N; scanf ("% lld", & N); long int now = 1; for (int I = 2; I <= N; I ++) {now = now * I; while (now % 10 = 0) now = now/10; now = now % 10000000 ;} printf ("% lld", now % 10); return 0 ;}