/**
* Angewandte Mathematik, SS11
* Problem: 568 Just the Facts
* Link: http://uva.onlinejudge.org/external/5/568.html
*
* @author Fabian Trampusch
* @author Robert Schwarz
* @version 1.0, 31/03/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.452
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BigInteger d = new BigInteger("10");
BigInteger zero = new BigInteger("0");
BigInteger h = new BigInteger("1");
while (true) {
String input = reader.readLine();
if(input == null)
break;
BigInteger i = new BigInteger(input);
BigInteger n = i;
BigInteger f = n;
while (n.compareTo(h) == 1) {
f = f.multiply(n.subtract(h));
n = n.subtract(h);
}
BigInteger m = f.mod(d);
while (m.equals(zero)) {
f = f.divide(d);
m = f.mod(d);
}

if (i.compareTo(d) == -1) {
System.out.println(" " + i + " -> " + m);
} else if (i.compareTo(d.multiply(d)) == -1) {
System.out.println(" " + i + " -> " + m);
} else if (i.compareTo(d.multiply(d.multiply(d))) == -1) {
System.out.println(" " + i + " -> " + m);
} else if (i.compareTo(d.multiply(d.multiply(d.multiply(d)))) == -1) {
System.out.println(" " + i + " -> " + m);
} else {
System.out.println(i + " -> " + m);
}
}
}
}

2.

/**
* Angewandte Mathematik, SS11
* Problem: 568 - Just the Facts
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=509
*
* @author Benjamin Vogt
* @author Sebastian Stumpf
* @version 1.0, 04/04/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.540
*/

import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
static BigInteger fak(int number)
{
BigInteger big = BigInteger.ONE;
if(number == 0 || number == 1)
return big;
if(number>1)
{
for(int i = 1; i<=number;i++)
{
big = big.multiply(BigInteger.valueOf(i));
}
}
return big;
}

public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int number;
char digit = '0';
String numb;
String numberStr;
BigInteger big = BigInteger.ONE;
while(sc.hasNextInt())
{
numberStr = sc.next();
number = Integer.valueOf(numberStr);
if(number<10000 && number >=0)
{
big = fak(number);
numb = String.valueOf(big);
int i = numb.length()-1;
while(digit == '0')
{
digit = numb.charAt(i);
if(digit != '0')
{
System.out.format("%5S -> "+digit+"%n",String.valueOf(number));
}
i--;
}
digit = '0';
}
}
System.exit(0);
}
}
---------------------------------------------------------------------------------------------------------
1.


/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 568 Just the Facts
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=509
*
* @author Anton Pavlushko, IBB7B,
* @version 1.0, 10/10/2010
*
* Status : Accepted
* Runtime: 0.144
*/

import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String current_line, empty = "";
int number, length;
double znak,count5,i,count5_already,multiply;

try {
while ((current_line=in.readLine())!= null) {
length=current_line.length();
number = Integer.parseInt(current_line);
znak=Math.floor(Math.log10(number)/Math.log10(5));

if (number<=Math.pow(5,znak+1)) znak++; //2.999999999996 Problem...

count5=0;
for(i=1;i<=znak;i++) {
count5_already=Math.floor(number/Math.pow(5,i));
count5+=count5_already;
}

znak=1;
count5_already=0;
for(i=2;i<=number;i++) {
multiply=i;
if (count5_already<count5 && multiply%2==0) {
multiply=multiply/2;
count5_already++;
}

while (multiply%5==0) multiply=multiply/5;
znak=(multiply*znak)%10;
}

empty="";
length=5-length;
for(i=0;i<length;i++) empty+=" ";

System.out.println(empty+number+" -> "+Math.round(znak));
} // end while
} // end try
catch (IOException e) {
System.err.println("Error: " + e);
}
}
}