Lost PrimesProblem code: L3 |
All submissions for this problem are available.
The BSA (Bytelandian Security Agency) has intercepted several secret keys from the Trojan Kingdom. Each secret key is a prime number. But BSA was only able to retrieve some part of the digits, not all of them!
Johnny's job is to help BSA recover these lost primes, and he has delegated the task to you!
Input
The first line contains a number t (about 15) which is the number of test cases. Then t test cases follow. Each test case is described in a single line containing the patterns of the lost primes (the unknown digits are represented by '?'s.
Each pattern's length is at most 12.
Output
For each test case, print the recovered prime. If there are multiple solutions, print any of them. The recovered prime should have the same number of digits as the corresponding pattern and should contain no leading zeros.
You can assume that there is at least one solution for each test case.
Example
Input: 3 ? ?3 1?? Output: 5 23 101
| Author: | duc_admin |
| Date Added: | 15-12-2009 |
| Time Limit: | 4 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

plz help me.. i hav tried
plz help me..
i hav tried submitting this prob many times but it always says "Wrong answer"..
admin can u plz tell me the test case for which it is giving the wrong answer as I have tested various test cases succcessfully on my system..
I am getting run-time
I am getting run-time error(SIGSEGV). Can someone tell me why I am getting this error?
My submission ID is 169225.
@Pankaj: usually the
@Pankaj: usually the testcases are posted after a contest, but this time they weren't (or if they were, I can't see where). Just a suggestion: have you tried a testcase of "?" And at least one testcase of length 12? And some testcases with no question marks at all?
@john:thanx for the
@john:thanx for the suggestion but I hav already tried all of des test cases and am gettng the desired output..
dunno wats d mistake..admin plz help..
char
char s[12];..
scanf("%s",s);
That definitely won't work on a string of length 12.
I'm compelled to write to you
I'm compelled to write to you as I'm really curious to know what is expected out of programmers in this problem. It is quite clearly mentioned that any of the prime numbers can be taken if there are multiple prime numbers of the same digits. I've tried and tested my program several times and got it correct. Even now I'm getting "WRONG ANSWER" when I submit my solution. Kindly clarify the problem.
Plz help
Plz help
Kindly clarify the question
Kindly clarify the question or modify the test engine to accept the correct answer. As per what is asked I'm getting the correct output but the compiler is rejecting it every time I submit my solution. Plz throw some light on this problem.
@king: at least 147 unique
@king: at least 147 unique solutions, accepted as correct by the judge, have been posted between this page and the corresponding page under the January competition, all of which are viewable. why not pick one in your preferred language and read it? or at least tell us what needs to be clarified.
Codechef is rejecting your
Codechef is rejecting your solution because it is very plainly incorrect for a huge number of reasons. Please read the FAQ before making another comment.
(You say you tested your code, but that seems very unlikely as it giving the wrong results for virtually all test cases I can think of.)
@John My situation is also
@John
My situation is also similar to Pankaj.
Tried with all test cases i can think of (ofcourse including 12'?')
One doubt..
If input is pattern don't have any '?' and not a prime, then what should be output ?
say '1222'
Right now i am printing same pattern for them. '1222'
Is this correct ?
Shoonya !!
@stephen:got my
@stephen:got my mistake...
thanx a lot...
@Mohit: what you're doing is
@Mohit: what you're doing is correct, but there are no such nonprime constants in the list, apparently.
if you're using optimized input routines, watch out for DOS-type endlines of rn rather than just n. not sure this is one of those, but there are a few problems with input files like that.
@ Mohit Tried with all test
@ Mohit
Tried with all test cases you could think of? It seems to fail on most of them. For example, ?3; you print out 17.
Hi, I have been trying my
Hi,
I have been trying my solution for a lot of times now... I always get a Runtime Error. Could it be because of the memory... although I may be wrong... but I think that the code seems to be working well with all the test cases that I could think of... also I have not faced any Runtime Exception yet.
Regards.
Sunil
One reason that you will
One reason that you will definitely get a runtime exception with that code is mentioned in the FAQ.
@Stephen: thank you for your
@Stephen: thank you for your comment. The issue was with memory and also I did not return the main() with "return 0". I guess I should be reading the FAQ more carefully :). Thank you again.
My submission id is 702373.
what is the maximum limit