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.

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 ?

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.

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.