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?
897 - Anagrammatic Primes
Moderator: Board moderators
-
- New poster
- Posts: 13
- Joined: Wed Oct 26, 2005 10:14 pm
- Location: Iran
- Contact:
Well, I thought your fault is in negative inputs!
anyway, instead
put after your main loop:
anyway, instead
Code: Select all
if(number>1000)
cout<<0<<endl;
Code: Select all
if(go)cout<<0<<endl;
[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 ]
[ I 've written a correct soln now which got ACC and it's not precalculated ]
regards,
nymo
nymo
-
- Experienced poster
- Posts: 147
- Joined: Mon Jun 07, 2010 11:43 am
- Location: University Of Dhaka,Bangladesh
- 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.
UVa stats: http://felix-halim.net/uva/hunting.php?id=63448
My blog on programming: http://www.shafaetsplanet.com/planetcoding/
My blog on programming: http://www.shafaetsplanet.com/planetcoding/
-
- 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?
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?
-
- 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.
-
- New poster
- Posts: 3
- Joined: Fri Feb 14, 2020 9:43 am