@@ -0,0 +1,755 @@
+import java.util.*;%0Aimport static java.lang.Math.*;%0Aimport java.util.stream.*;%0A%0A/*%0AProblem name: 10212 The Last Non-zero Digit.%0AProblem url: https://uva.onlinejudge.org/external/102/10212.pdf%0AAuthor: Andrey Yemelyanov%0A*/%0Apublic class _10212 %7B%0A  public static void main(String%5B%5D args)%7B%0A    Scanner s = new Scanner(System.in);%0A    while(s.hasNext())%7B%0A      System.out.println(getLastDigit(s.nextInt(), s.nextInt()));%0A    %7D%0A  %7D%0A%0A  static int getLastDigit(int N, int M)%7B%0A    long result = 1;%0A    for(long i = N; i %3E N - M; i--)%7B%0A      result = discardTrailingZeros(result * i) %25 MOD;%0A    %7D%0A    return (int)(result %25 10);%0A  %7D%0A%0A  static final int MOD = 1000000000;%0A  static long discardTrailingZeros(long n)%7B%0A    while(n %25 10 == 0) n /= 10;%0A    return n;%0A  %7D%0A%7D%0A

10212 The Last Non-zero digit