1. 

/**
* 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();
}
}
}