Page 4 of 11

Hey Hey

Posted: Fri Oct 10, 2003 4:21 pm
by Riyad
Hey man ,
so smart of u :o . u r right about the check function . it wont work for 25 nor wil it work for 16 or 9 or 36 . There will be a slight change in the operator used in the function , instead of '<' it will be '<=' ,which some how i got it right and submitted the prob and got ac . thanx for u r notice .
Riyad

10235-Why?.. WA

Posted: Wed Oct 29, 2003 12:29 am
by shamim(aiub)
plz somebody tell me why WA?
i didn't find any mistake
[cpp]
#include<stdio.h>

long isprime(long x){
long i=2;
while(i*i<=x){
if(x%i==0) return 0;
i++;
}
return 1;
}
long rev(long x)
{
long r=0,i=1;
if(x<10) return x;
r=x;
while(r>9){
r=r/10;
i*=10;
}
r=0;
while(x>0){
r=r+((x%10)*i);
x=x/10;
i=i/10;}
return r;
}

void main()
{
long n,t;
freopen("E:\\acm\\10235.in","r",stdin);
freopen("E:\\acm\\10235.out","w",stdout);
while(scanf("%ld",&n)==1){
t=rev(n);
if(isprime(n)==0) printf("%ld not prime.\n",n);
else if(n==t||isprime(t)==0) printf("%ld is prime.\n",n);
else printf("%ld is emirp.\n",n);
}
}

[/cpp]

Posted: Wed Oct 29, 2003 8:14 am
by Joseph Kurniawan
I think you should revise your isprime() function.
For the input 6, your program will output:
6 is prime.
Where the correct output should be 6 is not prime.
Hope this helps!! :wink: :wink:

what is wrong

Posted: Sat Nov 01, 2003 7:00 pm
by shamim(aiub)
i think my isprime() function is OK.
and
for 6
OUTPUT:6 is not prime(correct)
i couldn't understand that u(Joseph Kurniawan) want to say.
PLZ reply

Posted: Sat Nov 01, 2003 8:22 pm
by Adrian Kuegel
Your isprime function is wrong for 1.
But anyway, as it is said that the input number n is > 1 this is not your problem. What about comparing your output to the sample output? I think you will see your mistake easily :)

Posted: Sun Nov 02, 2003 9:28 am
by shamim
HI Shamim!

I found one mistake in your code,

for 18, your output is
18 not prime

but the sample output says,
18 is not prime.

so, even with a correct algorithm, you will never get accepted, because the judge compares, your output with judges, character by character.

Good Luck!!

Posted: Sun Nov 02, 2003 9:33 am
by shamim
PS

How about changing your name if you do not mind. :P :lol: :D

I mean same name causes loss of our uniqeness. :)

just reply

Posted: Sun Nov 02, 2003 4:31 pm
by shamim(aiub)
i have solved the problem and got AC(without changing "isprime()").
there was some miskate.

to shamim,
should i change my ID?

shamim(aiub)

Posted: Mon Nov 03, 2003 10:31 am
by bery olivier
shamim wrote:PS

How about changing your name if you do not mind. :P :lol: :D

I mean same name causes loss of our uniqeness. :)
I tried to change my mane, but it is not an option. The board administrators chose not to let us change our name. I guess it's the right choice to prevent people change too many times. I would be confusing.
I don't really care about changing it anmore, but if You do, the only way is to ask the administrators to do it.
They won't do it for a lot of people, though.

Posted: Mon Nov 03, 2003 12:44 pm
by shamim
To Shamim(aiub)
to shamim,
should i change my ID?
Well, maybe you could do something, since you have not made so many posts, you could delete your current account and register again.

Posted: Sat Nov 08, 2003 4:29 pm
by Joseph Kurniawan
I'm really really sorry for the false info. It seems my BC is broken. Now I've fixed it. :oops: :oops: :oops: :oops:

10235 Why WA.

Posted: Fri Mar 05, 2004 8:19 am
by Kamanashish
CUT

Posted: Fri Mar 05, 2004 5:48 pm
by sidky
http://online-judge.uva.es/board/viewtopic.php?t=2004

1 or 0 are not even prime. So, they can't be emirp

Posted: Mon Mar 08, 2004 11:02 pm
by kiha
Hi,

I tested my program on all your tests,
I read all topics about 10235 -- Simply Emirp,
but I still get WA.

I apologise for putting my code here, but I can't work out what's wrong -- it seems to be all right :/
A little explanation :
s, os -- numbers read as strings : s -- read normally, os -- read backwards
g, og -- real numbers that I am to check
n, nn -- bools declaring : n -- whether original number is a prime, nn -- whether the same number read backwards is a prime

[pascal]

program miazio;


function odwr (s:string):string;
var
pk:byte;
qpa:string;

begin
pk:=length (s) + 1;
qpa:='';

repeat

dec (pk);
qpa:=qpa + s[pk]

until pk <= 1;

odwr:=qpa;
end;



var
s, os:string;
i, j, l, k, lp, p, g, og:longint;
n, nn:boolean;
kurde:set of char;


begin

kurde:=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];

while not eof do
begin

readln (s);

os:=odwr (s);
g:=0; og:=0;

for lp:=1 to length (s) do
g:=g * 10 + ord (s[lp]) - 48;

for lp:=1 to length (os) do
og:=og * 10 + ord (os[lp]) - 48;


lp:=0;
k:=1;
nn:=false;

repeat

inc (k);

if og mod k = 0 then
inc (lp);

until (k = trunc (sqrt (og))+1) or (lp > 0);

if (lp = 0) then
nn:=true;

lp:=0;
k:=1;
n:=false;

repeat

inc (k);

if g mod k = 0 then
inc (lp);

until (k = trunc (sqrt (g))+1) or (lp > 0);

if lp = 0 then
n:=true;

if g = 1 then n:=true;
if og = 1 then nn:=false;
if (g = 2) then n:=true;
if og = 2 then nn:=true;
if (og = g) and (n) then nn:=false;

if (not n) and (not nn) then writeln (g, ' is not prime.');
if n and (not nn) then writeln (g, ' is prime.');
if nn then writeln (g, ' is emirp.');

n:=false;
nn:=false;

end;

end.

[/pascal]

Posted: Tue Mar 09, 2004 2:53 pm
by alu_mathics
An Emirp (Prime spelt backwards) is a Prime that gives you a different Prime when its digits are reversed.
So
11 is not emirp.
You can use seive method.This will help u a lot.