1.

/**
* Angewandte Mathematik, SS11
* Problem: 324 - Factorial Frequencies
* http://uva.onlinejudge.org/external/3/324.pdf
* @author Sebastian Stumpf
* @author Benjamin Vogt
* @version 1.0, 2011-04-16 19:33:41

*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.120
*/

import java.io.*;
import java.math.*;

public class Main
{
public static void main(String[] args)
{
try {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String s = input.readLine();
int number = Integer.parseInt(s);
while(number != 0)
{
// BigInteger can handle numbers up to the needed max 366!.
BigInteger faculty = BigInteger.valueOf(number);
int[] frequencies = new int[10];
// the faculty of the current Number is calculated
for(int i = number-1; i > 1; --i)
{
faculty = faculty.multiply(BigInteger.valueOf(i));
}
// the BigInt is returned as a String
s = faculty.toString();
// iterates through s and rises the array frequencies at index of the current char by one
for(int i = s.length()-1; i >= 0; --i)
{
++frequencies[s.charAt(i) - '0'];
}
// output, format is not too critical for an accepted
System.out.println(number+"! --\n" +
" (0) "+frequencies[0]+" (1) "+frequencies[1]+" (2) "+frequencies[2]+" (3) "+frequencies[3]+" (4) "+frequencies[4]+"\n"+
" (5) "+frequencies[5]+" (6) "+frequencies[6]+" (7) "+frequencies[7]+" (8) "+frequencies[8]+" (9) "+frequencies[9]);

// getting next values
s = input.readLine();
number = Integer.parseInt(s);
faculty = BigInteger.valueOf(number);
}
} catch (IOException e) {e.printStackTrace();}
}
}

2.

/**
* Angewandte Mathematik, SS11
* Problem: 324
* Link: http://uva.onlinejudge.org/external/3/324.pdf
*
* @author Ritter Marius
* @author Wende Tom
* @author Zehentbauer Stefan
* @version 1.0, 04/18/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.136
*/

import java.math.BigInteger;
import java.util.Scanner;
public class Main {


public static void main(String[] args){
BigInteger i;
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
while(!(input == 0)){
i = BigInteger.ONE;
for(int j = 2; j <= input ;j++){
i = i.multiply(BigInteger.valueOf(j));
}
char[] charArr = i.toString().toCharArray();
int[] intArr = new int[10];
for(int j = 0;j<charArr.length;j++){
intArr[charArr[j]-'0']++;
}
System.out.println(input+"! --\n" + " (0) "+intArr[0]+" (1) "+intArr[1]+" (2) "+intArr[2]+" (3) "+intArr[3]+" (4) "+intArr[4]+"\n"+ " (5) "+intArr[5]+" (6) "+intArr[6]+" (7) "+intArr[7]+" (8) "+intArr[8]+" (9) "+intArr[9]);
input = scan.nextInt();
}
}
}

------------------------

1.


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

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: ##324## Factorial Frequencies
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=260
*
* @author Felix Dietrich
* @version 1.0, 14.10.2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.556
*/

public class Main
{
public static void main(String... strings)
{
Scanner sc = new Scanner(System.in);

BigInteger b = BigInteger.valueOf(1);
int[][] digits = new int[366][10];
int d = 0;
String s;

for(int i=0; i<366; i++)
{
b = b.multiply(BigInteger.valueOf(i+1));

s = b.toString();
for(int k=0; k<s.length(); k++)
{
d = Integer.parseInt(String.valueOf(s.charAt(k)));
digits[i][d]++;
}
}

while(sc.hasNext())
{
int num = sc.nextInt();
if(num == 0)
return;

System.out.println(String.format("%d! --", num));
for(int dig=0; dig<10; dig++)
{
System.out.print(String.format("(%d) %d ", dig, digits[num-1][dig]));
if(dig == 4)
System.out.println();
}
System.out.println();
}
}
}



2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 324 - Factorial Frequencies
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=260
*
* @author Felix Dietrich
* @version 1.0, 06/08/2010
*
* Method : BigInteger
* Status : accepted
* Runtime: 0.220
*/


import java.util.*;
import java.lang.*;
import java.math.*;

class Main
{
public static BigInteger[] store = new BigInteger[380];

public static void calcStore()
{
BigInteger result;
for(int n=1; n<store.length; n++)
{
result = BigInteger.ONE;
for(int i=1; i<=n; i++)
result = result.multiply(BigInteger.valueOf(i));
store[n] = result;
}
}

public static int[] countDigits(BigInteger b)
{
int[] result = new int[10];

String b_str = b.toString();
for(char c: b_str.toCharArray())
result[c-'0']++;

return result;
}

public static void main(String... args)
{
calcStore();

Scanner sc = new Scanner(System.in);

int n;
int[] digits;
BigInteger result;
while(sc.hasNext())
{
n = sc.nextInt();
if(n == 0)
return;

System.out.println(n + "! --");
digits = countDigits(store[n]);
for(int i=0; i<=4; i++)
System.out.printf(" (%d) %d", i, digits[i]);
System.out.println();
for(int i=5; i<=9; i++)
System.out.printf(" (%d) %d", i, digits[i]);
System.out.println();
}
}
}