1. Java, Gunnar Hage


/**
* FWP-Fach: ACM programming Contest WS 08/09 "10789 Prime Frecquency"
* Verdict: accepted / 0.230
*
* Gunnar Hage, gunnarhage@gmx.de
* AP5(IFB5A) Dez. 2008
Input:
3
ABCC
AABBBBDDDDD
ABCDFFFF

Output:
Case 1: C
Case 2: AD
Case 3: empty

*/

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
public static void main(String... args) throws IOException{
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cases = Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++)
{
int[] alphanumerals = new int[128];
boolean[] erastho = eratosthenes(2003);
String line = br.readLine();
//filter nach kleinbuchstaben.
for(char c:line.toCharArray())
if((c>='a' && c <='z')||(c>='A' && c <='Z')||(c>='0' && c <='9')) // ist diese bedingung richtig?
alphanumerals[c]++;

//Ausgabe
bw.append("Case " + (i+1) + ": ");
char current = 0;
boolean empty = true;
for(int f:alphanumerals)
{
if(!erastho[f])
{
bw.append(current);
empty = false;
}
current++;
}
if(empty)
bw.append("empty");
bw.append("\n");

}
bw.flush();
bw.close();
System.exit(0);
}

public static boolean[] eratosthenes(int upperBorder){
boolean[] gestrichen = new boolean[upperBorder];
gestrichen[0] = true;
gestrichen[1] = true;
for(int i = 2; i < upperBorder; i++)
gestrichen[i] = false;
int i=2;
while (i*i <= upperBorder){
if (!gestrichen[i]){
for(int j=i*i; j<upperBorder; j+=i)
gestrichen[j] = true;
}
i++;
}
return gestrichen;
}
}