Page 1 of 11

10235 - Simply Emirp

Posted: Mon Feb 25, 2002 11:36 am
by DemonCris
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

Posted: Mon Feb 25, 2002 11:43 am
by junjieliang
Read the definition for emirp properly. My program gives this output for input 131:

131 is prime.

Posted: Mon Feb 25, 2002 1:35 pm
by DemonCris
Thank you ^^

I got it ...

Posted: Tue Mar 05, 2002 3:09 pm
by stanley.cai
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
....

10235

Posted: Tue Mar 05, 2002 3:18 pm
by Alexandru Mosoi
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

Posted: Tue Mar 05, 2002 4:04 pm
by cyfra
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 :smile:

Posted: Wed Mar 06, 2002 4:08 am
by C8H10N4O2
I am having the same problem. Does anyone know whether it is a bad test set?

Posted: Wed Mar 06, 2002 5:27 am
by Stefan Pochmann
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.

10235

Posted: Wed Mar 06, 2002 1:38 pm
by C8H10N4O2
Everyone gets PE. Can someone from OJ check it out?

Posted: Mon Jul 01, 2002 4:24 pm
by JWizard
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 ?

Posted: Mon Jul 01, 2002 7:01 pm
by 10153EN
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?

Look the sample outputs!!!!!

Posted: Mon Jul 01, 2002 7:02 pm
by SuperBug!
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!

Posted: Mon Jul 01, 2002 7:26 pm
by 10153EN
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.

Posted: Mon Jul 01, 2002 7:59 pm
by JWizard
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

Posted: Mon Jul 01, 2002 8:23 pm
by 10153EN
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~