## 10235 - Simply Emirp

Moderator: Board moderators

DemonCris
New poster
Posts: 25
Joined: Sun Feb 24, 2002 2:00 am
Location: Taiwan

### 10235 - Simply Emirp

Is there any special case ?
I have got lots of WA.

I have consider many numbers as following:
1000 -> 1 not prime
2 -> 2 emirp
...etc

junjieliang
Experienced poster
Posts: 169
Joined: Wed Oct 31, 2001 2:00 am
Location: Singapore
Read the definition for emirp properly. My program gives this output for input 131:

131 is prime.

DemonCris
New poster
Posts: 25
Joined: Sun Feb 24, 2002 2:00 am
Location: Taiwan
Thank you ^^

I got it ...

stanley.cai
New poster
Posts: 1
Joined: Tue Mar 05, 2002 2:00 am
I have noticed it, but I gets lots of WA.
Does it have some others special input,
just like 00002, 00013?
My program outputs:
2 is prime
131 is prime
....

Alexandru Mosoi
New poster
Posts: 5
Joined: Wed Feb 20, 2002 2:00 am

### 10235

while(scanf("%d", &x) == 1)
{
if(!prime(x)) printf("%d is not prime.n", x);
else
if(!prime(reverse(x)) || x == reverse(x)) printf("%d is prime.n", x);
else printf("%d is emirp.n", x);
}

This is my (main) source code.
Why do I get P.E.?

prime(x) - tests if x is prime
reverse(x) - returns x spelled backwards

cyfra
Experienced poster
Posts: 144
Joined: Thu Nov 22, 2001 2:00 am
Location: Gdynia, Poland
Hi!

Maybe you will consider this test data...

1 - not prime
2 - prime
3 - prime
4 - not prime
5 - prime
6 - not prime
13 - emirp
31 - emirp
19 - prime
91 - not prime (!)

Look especially at the last test case...

Good Luck...

PS.
Maybe you forgot about a dot or made a mistake while writing the output...
Check this

C8H10N4O2
Experienced poster
Posts: 137
Joined: Wed Feb 27, 2002 2:00 am
I am having the same problem. Does anyone know whether it is a bad test set?

Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:
Since *everbody* only got a "P.E.", there's definitely something wrong with the judge. I usually don't bother fixing P.E.'s, because most of the time it's not my fault.

C8H10N4O2
Experienced poster
Posts: 137
Joined: Wed Feb 27, 2002 2:00 am

### 10235

Everyone gets PE. Can someone from OJ check it out?

JWizard
New poster
Posts: 5
Joined: Mon Jul 01, 2002 4:21 pm
Contact:
Hi, I tried all the above test data as well as some of my own, but for some reason I keep getting WA... and I'm pretty sure that my output is well formatted.... any ideas ?

10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:
Not much idea, as the output is straight-forward, except the full-stop at the end of the line.

Would you post your outputs for N = 1-30 and N = 999970-1000000?

SuperBug!
New poster
Posts: 1
Joined: Sat Jun 29, 2002 10:10 am
Location: Spain
Contact:

### Look the sample outputs!!!!!

Look the sample outputs!!!!! Does your program puts the end dot? When writing the outputs, be sure not to write the left-leaddings ceros. You could be printing the number as string. When output the solutions, the save way is to handle the numbers as not-string (integer, long integer...) You could have an error in your handling string routine!!!
Bye!

10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:
I agree with the full-stop in the outputs. But to handle the string? This problem need not to deal with strings, but just prime number calculations.

JWizard
New poster
Posts: 5
Joined: Mon Jul 01, 2002 4:21 pm
Contact:
Output:

N=1-30:
Prime: 2, 3, 5, 7, 11, 19, 23, 29
Not prime: 1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25,26, 27, 28, 30
Emirp: 13, 17

N=999970-1000000
Not Prime: 999970, 999971, 999972, 999973, 999974, 999975, 999976, 999977, 999978, 999980, 999981, 999982, 999984, 999985, 999986, 999987, 999988, 999989, 999990, 999991, 999992, 999993, 999994, 999995, 999996, 999997, 999998, 999999, 1000000
Prime: 999979
Emirp: 999983

10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:
Same as mine. I think the problem is of no problem. Finally, would you please copy-and-paste your outputs here so as to give me a look?

I think it's the final thing remaining to check~