1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10235 Simply Emirp
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1176
*
* @author Barny Porcio
* @version 1.0, 03/25/2010
*
* Method : Sieb des Eratosthenes
* Status : Accepted
* Runtime: 1.004
*/
import java.io.IOException;
import java.util.Scanner;


public class emirP {
static short[] answer;

/** Sieb des Eratosthenes, belegt emirp zahlen mit 1 und nicht prim zahlen mit -1 */
static void initialiser(){
answer = new short[1000001];
//belegt erstmal nur nichtprimzahlen mit -1
for (int i = 2;i<= Math.sqrt(answer.length);++i){
if (answer[i]!=-1){
for (int c=2;(c*i)<answer.length;++c){
answer[c*i]=-1;
}
}
}

//primzahlen, deren gespiegelte zahlen != sich selbst auch primzahlen sind werden auf 1 gesetzt
for (int i = 2;i<answer.length;++i){
if (answer[i]==0){

int reverse = 0;
int alt = i;
while (alt!= 0){
reverse = reverse * 10 + alt % 10;
alt = alt / 10;
}
if(reverse != i){
if (answer[reverse]==0){
answer[i]=1;
answer[reverse]=1;
}
}
}
}
}
/**
* @param args
*/
public static void main(String[] args)throws IOException {
initialiser();
Scanner scanner = new Scanner(System.in);
//es wird nur noch ueberprüft ob der gesuchte wert 1, 0 oder -1 ist und die richtige ausgabe getroffen
while(scanner.hasNextInt()){
int temp = scanner.nextInt();
if (answer[temp]== 0)System.out.println(temp+" is prime.");
if (answer[temp]== -1)System.out.println(temp+" is not prime.");
if (answer[temp]== 1)System.out.println(temp+" is emirp.");
}

}

}


2. Martin Lambeck

package acm_10235_simply_emirp;

import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
static boolean[] sieb = new boolean[1000000];

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

fill(sieb.length);

while (sc.hasNextInt())
{
int n = sc.nextInt();

if (sieb[n])
{
if (sieb[reverse(n)] && (n != reverse(n)))
{
System.out.println(n + " is emirp.");

} else
{
System.out.println(n + " is prime.");
}

} else
{
System.out.println(n + " is not prime.");

}
// reverse(sc.nextInt());
// System.out.println(sieb[sc.nextInt()]);

}

}

public static void fill(int n)
{
int i = 1;
int mul;

Arrays.fill(sieb, true);
sieb[0] = false;
sieb[1] = false;

while (true)
{

i++;

mul = i * i;

if (!sieb[i])
continue;

if (mul >= n)
return;

while (mul < n)
{
sieb[mul] = false;
mul += i;
}

}
}

static int reverse(int n)
{
int rev = 0;
int div = 1;
int mod = 0;
int mul = 10000000;

while (div < 10000000)
{
mod = n % (div * 10);
n -= mod;
mod = mod / div;

div = div * 10;

rev += mul * mod;
mul = mul / 10;
}

while (rev % 10 == 0)
{
rev = rev / 10;
}

return rev;
}
}

3.

1.



/**

 * Angewandte Mathematik, SS09, IFB 2C

 * ACM Problem 10235 - Simply Emirp

 * Link:
http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1176

 * @author Miesel Christoph

 * @author Seilbeck Robert

 * @author Wolfram Andre

 * @version 1.0 25.03.2009

 *

 * Status : Accepted

 * Runtime: 0.630

 */



import java.io.*;





public class Emirp {

    

    static boolean primzahltest(int aNumber)

    {

    boolean isPrim = true;

    if(aNumber==2) isPrim = true;

    else

    {

        double limit = Math.sqrt(aNumber);

        if(aNumber%2==0) isPrim = false;

        for(int i = 3; i<=limit; i+=2)

            {

          
 if(aNumber%i==0) isPrim = false;

            }

    }

    return isPrim;

    }

    

    

    public static void main(String[] args) throws
Exception

    {

        

        BufferedReader reader = new
BufferedReader(new InputStreamReader(System.in));

        String line = reader.readLine();

        int input = -1;

        int revert = 0;

        while(line!=null)

        {

            

            input =
Integer.parseInt(line);

            int tmp =
input;

            while(tmp != 0)

            {

              
 revert = revert * 10 + tmp % 10;

              
 tmp /= 10;

              
 

            }

        if(primzahltest(input) &&
primzahltest(revert) && input != revert)

          
 System.out.println(input+" is emirp.");

        else {

          
 if(!primzahltest(input)) System.out.println(input+" is not
prime.");

            else
System.out.println(input+" is prime.");

            }

        line = reader.readLine();

        revert = 0;

        }

        }

    }