## 967 - Circular

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

Moderator: Board moderators

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

### 967 - Circular

Seems it is the first post of this problem. Circular

Isn't it true that all the valid numbers consist only the digits {1, 3, 5, 7}.

I basically generated all the numbers in the range [100, 1000000) using recursion and checked the validity. But I am getting WA.

Input: 100 999999
Output: 42 Circular Primes.

Is it correct?

stubbscroll
Experienced poster
Posts: 151
Joined: Tue Nov 16, 2004 7:23 pm
Location: Norway
Contact:
Your answer is correct, but there are many valid numbers containing 9 (and none containing 5).

Did you remember to output Prime without an ending s when the answer is one? It's the only trap I can think of.

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

### oooppsss

ooopss..

I meant to write { 1, 3, 7, 9}.. and not {1, 3, 5, 7}
any other ideas?

: got accepted.... made a stupid/silly mistake in printing.

mpi
New poster
Posts: 46
Joined: Fri Nov 03, 2006 7:53 pm
Location: Madrid
i'm following the same approach than you and i always get TLE. After generating all circular primes between 100..1000000, i only have to do a simple iteration through my array and count the 1's. It's simple, but however i get TLE.

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan
mpi wrote:i only have to do a simple iteration through my array and count the 1's.
This approach is too slow. Think about it. (there are just fourty few cir-primes)

mpi
New poster
Posts: 46
Joined: Fri Nov 03, 2006 7:53 pm
Location: Madrid
You are right. There are only 42 numbers. What i was thinking about?
Now i get AC in 0.674s.

Thanks

farzane
New poster
Posts: 26
Joined: Thu Jun 15, 2006 9:26 am
could someone please help me and tell me what's wrong with this code?
I'm getting WA.It is an easy problem I think so.

Code: Select all

``removed``
Last edited by farzane on Fri Nov 10, 2006 1:14 pm, edited 1 time in total.

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan
cir[9] = 917, but its not a prime.So check why this number pass your Circular prime test.

farzane
New poster
Posts: 26
Joined: Thu Jun 15, 2006 9:26 am
Thank you very much rio.I found my mistake ang got AC.

Rupak
New poster
Posts: 8
Joined: Mon Jan 15, 2007 6:53 am
Location: Bangladesh
I think i can't understand the problem statements .

For 917 we should check the numbers 917, 179 and 791 .
Here 917 isn't prime, 179 is prime and also 791 isn't prime .
So can we call the number 917 be a circular prime ?
_______________________________________
http://acm.uva.es/problemset/usersnew.php?user=6114

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
No, 917 is not a circular prime.. because 917 and 791 is not a prime as you said..

sumantbhardvaj
New poster
Posts: 19
Joined: Sun Jun 18, 2006 4:07 pm
Contact:
Somebody plz provide me some test case.. I m constantly getting wrong answer for this problem..thanx in advance

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
I don't think there are any special cases. If you find 42 circular primes between 100 and 1000000, as mentioned above, you have a very good chance that your program is right. Your only worry then is to get the output format right. Have you carefully checked your output for the sample input?
The biggest problem with most problems is not how to solve the problem, but how to not solve what is not the problem.

sumantbhardvaj
New poster
Posts: 19
Joined: Sun Jun 18, 2006 4:07 pm
Contact:
yeah ! you are absolutely right. I was not printing correctly when we have output 1. later on i found the mistake and got AC .why do acm problems have such irrelevant output formats.. i nearly wasted 1 hr for that.

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am
i got wa.
what's wrong with my code???

Code: Select all

``````ACed
``````
Last edited by hamedv on Mon Jul 30, 2007 11:16 am, edited 1 time in total.