897 - Anagrammatic Primes

All about problems in Volume 8. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

clare
New poster
Posts: 7
Joined: Wed Aug 23, 2006 5:19 pm

Post by clare »

Sorry, I don't see what u mean :oops: 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? :o
smile2ka10
New poster
Posts: 13
Joined: Wed Oct 26, 2005 10:14 pm
Location: Iran
Contact:

Post by smile2ka10 »

Well, I thought your fault is in negative inputs!
anyway, instead

Code: Select all

if(number>1000)
cout<<0<<endl;
put after your main loop:

Code: Select all

if(go)cout<<0<<endl;
clare
New poster
Posts: 7
Joined: Wed Aug 23, 2006 5:19 pm

Post by clare »

Finally AC :D ! You were right! That was the mistake.

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

[897] input file is too weak...

Post by nymo »

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 :oops: 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 :wink: ]
regards,
nymo
Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh
Contact:

Re: 897 - Anagrammatic Primes

Post by Shafaet_du »

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

Post by alekscooper »

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

Post by alekscooper »

I'm gonna answer my own question: Yes, it works, I didn't get a TLE.
Fleurnoir488
New poster
Posts: 3
Joined: Fri Feb 14, 2020 9:43 am

Womans from your town

Post by Fleurnoir488 »

Post Reply

Return to “Volume 8 (800-899)”