## 897 - Anagrammatic Primes

Moderator: Board moderators

clare
New poster
Posts: 7
Joined: Wed Aug 23, 2006 5:19 pm
Sorry, I don't see what u mean Of course that 1 is a power of ten.
But, one is the next power of ten that is greate than zero. However, in this problem zero marks the end of the input.

Am I wrong?

smile2ka10
New poster
Posts: 13
Joined: Wed Oct 26, 2005 10:14 pm
Location: Iran
Contact:
Well, I thought your fault is in negative inputs!

Code: Select all

``````if(number>1000)
cout<<0<<endl;
``````

Code: Select all

``````if(go)cout<<0<<endl;
``````

clare
New poster
Posts: 7
Joined: Wed Aug 23, 2006 5:19 pm
Finally AC ! You were right! That was the mistake.

Thanx!

nymo
Experienced poster
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

### [897] input file is too weak...

Hi, i submitted a completely wrong solution having around 60 anagrammatic prime numbers in the range and it got ACC. Actually, I submitted the same code for another prime related problem with input-output modification and that code had some numbers more than 1000. So, I guess there are either very few input greater than 1000 or I must consider myself very lucky.

[ I 've written a correct soln now which got ACC and it's not precalculated ]
regards,
nymo

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Contact:

### Re: 897 - Anagrammatic Primes

This is a tough problem at first glance but as you sort out how to generate the primes this becomes very easy. There are only 22 anna prime but please dont copy them from here,try to generate them by your own.

alekscooper
New poster
Posts: 7
Joined: Thu May 21, 2015 9:52 pm

### Re: 897 - Anagrammatic Primes

Hello everyone,

could you guys please explain the following: Suppose I don't know how many annagramatic numbers there are and I want to do what the problems asks me to. Since N is less than 10,000,000, and I can input, for example, 8000000, I might need to generate 7! permuations for 1 number. I know I can optimise, there's no need to generate permutations if a prime contains any of {0, 2, 4, 5, 6, 8}. But even with this optimisation, won't it take too long to compute? For permutations I'll have to turn a number into a vector, fun next_permutation and then convert the vector back to a number. Isn't that all too long?

alekscooper
New poster
Posts: 7
Joined: Thu May 21, 2015 9:52 pm

### Re: 897 - Anagrammatic Primes

I'm gonna answer my own question: Yes, it works, I didn't get a TLE.