1.
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
* Angewandte Mathematik, SS11
* Problem: 10338 - Mischievous Children
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=15&page=show_problem&problem=1279
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 18/5/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.232
*/

public class Main {
public static void main(String[] args) throws Exception {
int count = 1;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int datasets = new Integer(reader.readLine());
for(int i = 0; i < datasets; i++){
char[] word = reader.readLine().toCharArray();
long[] factor = new long[word.length+1];
int[] letter = new int[26];
factor[0] = 1;
for(int j = 0;j < word.length;j++){
factor[j+1]=factor[j]*(j+1);
letter[word[j]-'A']+=1;
}
long result = 1;
for (int k : letter) {
if (k>1) result*=factor[k];
}
result=factor[word.length]/result;
System.out.println("Data set "+(count++)+": "+result);
}
}
}

2.

/**
* Angewandte Mathematik, SS11
* Problem: 10338 - Mischievous Children
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=15&page=show_problem&problem=1279
*
* @author Markus Schöllner
* @author Andreas Maier
* @version 1.0, 05/22/2011
*
* Method : Ad-Hoc
* Status : In judge queue
* Runtime:
*/
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

int cases = input.nextInt();
String word;
int wordLength;
int[] frequency;
BigInteger number,denom,resultDenom;

for(int c = 1; c <= cases;c++){
word = input.next();
wordLength = word.length();
frequency = new int[26];

number = BigInteger.ONE;
resultDenom = BigInteger.ONE;
for(int i=wordLength; i>0;i--){
number = number.multiply((BigInteger.valueOf(i)));

frequency[word.charAt(i-1)-'A']++;
}
for(int i = 0; i < 26;i++){
if(frequency[i] > 1) {
denom = BigInteger.ONE;
for(int k=frequency[i]; k>0;k--){
denom = denom.multiply((BigInteger.valueOf(k)));
}
resultDenom = resultDenom.multiply(denom);
}
}
System.out.println("Data set "+c+": "+number.divide(resultDenom));
}
}
}