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
Comments

Fetching successful submissions

for above test cases:---- the
for above test cases:----
the answers
2
13
101
will be correct or not??????????
Read the second sentence
Read the second sentence after 'Output'.
you can print any of them..
you can print any of them..
what can be maximim numbrer
what can be maximim numbrer of missing digits
any idea
may be all are missing...in
may be all are missing...in that case you have to print any prime containig those may digits..
is long long allowed in c
is long long allowed in c programming?
Yes
Yes
are we allowed to precompute
are we allowed to precompute things and read from a file ?
Thanks,
Ani
can any one help me with i/o
can any one help me with i/o stream in java... Can we use BufferedReader??
File access is not
File access is not allowed.
@amit click on Discuss - Wiki at the top of the page.
For some reason, they are
For some reason, they are showing the message "problem_id_required" just when I'm trying to submit this problem. The main page is showing that I have been getting TLE, but I keep on getting the same old "problem_id_required" message. What's going wrong? I tried both the button, the one on the right and the one at the bottom left. I submitted in CodeChef before, but this is the first I have been facing this problem. Can anybody help? As far as I know, there should be a small box showing the judge verdict after submitting a problem. Am I missing something new?
tarif
Oh! Finally the invisible
Oh! Finally the invisible "problem_id" appeared! thanks :D
for above test case can the
for above test case
can the answer be
7
43
103
@prince yes
@prince
yes
can you please check if my
can you please check if my code is wrong or not as the compiler for php seems to have some problem... for every test inputs it gives me correct answer but your compiler says it as wrong answer ! .. kindly confirm !
Not relating to the above
Not relating to the above question, but a general question : What does the Accuracy ( the stat on the rightmost column of every problem ) mean ?
i get always wrong
i get always wrong answer....but i cn't understand where i m worng....plzzzzz someone help...
dat is my code where i m worng plz tell me..
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
int main()
{
int a[14];
char s[14];
int b,c,i,k;
while(scanf("%s",s)!=EOF){
k=strlen(s);
c=0;
for(i=0;i<k;i++)
{
if((s[i]=='?')&&i!=k-1)
a[i]=abs(i-1);
else if((s[i]=='?')&&(k==2)&&(s[i-1]!='3'))
{
if(c%3==0)
a[i]=7;
else
a[i]=3;
}
else if(s[i]=='?')
{
c=c+7;
if(c%7==0)
a[i]=1;
else if(c%3==0)
a[i]=3;
else
a[i]=7;
}
else
{
c=c+s[i]-'0';
a[i]=s[i]-'0';
}
}
for(i=0;i<k;i++)
printf("%d",a[i]);
printf("n");
}
return 0;
}
@Uday: Accuracy is
@Uday: Accuracy is 100*(number of correct submissions)/(total number of submissions). It's value roughly reflects the difficulty of a problem, but sometimes (especially with the tiebreaker problem) is skewed by people who make multiple correct submissions.
@mukul: posting code is not allowed during the contest. Nor is posting hints.
I submitted solution in java.
I submitted solution in java. Its consuming 220MB memory.I am getting Error(OTHER).
Whats the memory limit for running this progra?
Thanks
plz someone help me....give
plz someone help me....give me some test case .........
thankxxxxxx
No, nobody can do that.
No, nobody can do that.
Hi, am trying to use long
use: long long var =
use:
long long var = 999999999999LL;
Please don't give away hints
Please don't give away hints related to contest problems.
Will the test case contain a
Will the test case contain a prime number with out the ? mark... In this case the app need to print the number as it is...
Will the ? appear only in front and end or any where in the number?
it is my worst experience on
it is my worst experience on codechef ...
this time for taking any input (pattern) i used #include<string> and string data type..........
and i got TLE about 15 times :( :(
but when i changed and used shar datatype 4 inputing pattern it took only 0.41 sec ................
Plz xplain why it happened.........
from TLE(>4sec) to 0.41 sec is big difference it means we must use char data type rather than string??????????????????????
plz help
it is my worst experience on
it is my worst experience on codechef ...
this time for taking any input (pattern) i used #include<string> and string data type..........
and i got TLE about 15 times :( :(
but when i changed and used *char datatype for inputing pattern it took only 0.41 sec and got AC................
Plz xplain why it happened.........
from TLE(>4sec) to 0.41 sec is big difference it means we must use char data type rather than string??????????????????????
plz help
I don't think that this is
I don't think that this is the case. I took your code which ran in 0.41 seconds and changed it to accept input using strings and it got accepted. Your code might have timed out because of other inefficiences.
Will the test case contain a
Will the test case contain a prime number with out the '?' mark... In this case the app need to print the number as it is...
Will the '?' appear only in front and end or any where in the number?
@Sundaram Have you read the
@Sundaram Have you read the third sentence of the problem statement?
If ? could only occur at the start or end, it would say ? can only occur at the start or end. It doesn't.
thnx for quick reply :). as u
thnx for quick reply :).
as u said aniruddha i tried again with string data type and got TLE :(
submission id is 159816 and 159817(tried 2 times)
i hv compiled my code in
i hv compiled my code in turbo c n it runs fine!!without error n warnings.
i hv uploaded d file here n it gives following compilation error
/tmp/ccT20vDe.o: In function `main': tested.c:(.text+0x13): undefined reference to `clrscr' tested.c:(.text+0x405): undefined reference to `strrev' tested.c:(.text+0x45f): undefined reference to `getch' tested.c:(.text+0x51b): undefined reference to `strrev' collect2: ld returned 1 exit status
anyone plz help fast!!
Don't use turbo C. Read
Don't use turbo C. Read www.codechef.com/wiki
i ma used 2 turbo c i hvnt
i ma used 2 turbo c
i hvnt used any other compliler evn 1nce!!
plz tell me hw 2 write code in dev cpp(i hv dwloaded)
is der any difference in code btwn turbo c and dev c!!
if yes what r dey?
Read the wiki.
Read the wiki.
Hi Admin, I have submitted
Hi Admin,
I have submitted my code three time and all the three times it says wrong answer. However the code working fine in my system. Can you tell me to which test case my code fails.... will a newline at the end or in the begining also matters in the output? Please help me....
Thanks & Regards
Sundaram. D
Newline at the end won't
Newline at the end won't matter. The code is tested against test cases other than the ones mentioned in the problem statement. The data with which you are testing your code might not be as exhaustive.
i m getting tle error in my
i m getting tle error in my program!!
in every time i make some change i hv 2 upload and check if it sits into the given time.
is der any way to find out the time into dev's compiler? or ur computer without uploading to dis dite!!
The system specs are
The system specs are mentioned in the wiki. You could try setting up your computer in the same way.
Speaking english so people could understand you might help too ;)
I hav submitted my code in
I hav submitted my code in C..But I gt a 'wrong answer' error...
The code seems to be working fyn on my system and I hav also tried various test cases...Can I plz know the test case for which my code
failed..
Nope, not until after the
Nope, not until after the contest.
The time limit of 4 s is
The time limit of 4 s is for one test case or for multiple test cases. I am assuming one test case = 1 input file with t number of inputs. So 4s , is it for one input file or multiple input files ?
One set of inputs = Number of
One set of inputs = Number of test cases followed by those many test cases. The time limit for all this is 4 seconds.
Do the known digits can be
Do the known digits can be more than one?
Please be more specific.
Please be more specific.
i m not getting the result
i m not getting the result for my submission.
plz somebody help me!!
the process keeps on running.
the process keeps on running.
Hi, I submitted my solution
Hi,
I submitted my solution and getting a runtime error.Where can i exactly see wht type of run time error is it.Cause its working fine in my desktop.
Like can this be the input :
Like can this be the input : ??3??1?
Like can this be the input :
Like can this be the input : ??3??1?
Of course.
Of course.
hi Aniruddha my code is
hi Aniruddha
my code is working but codechef is saying wrong ans...
can u throw some light
to the Admin for the below
to the Admin
for the below input
521??25?11???3?7?5 my program is giviing output like
521312521103031725
is the answer correct?
if yes then
i guess in all the circumstances my answer is giving right output then why judje is givin me wrong answer.. Admin please assist.
@nikhil and Parth No, the
@nikhil and Parth
No, the admin cannot help you. This is a contest problem.
@Parth Gupta Your input is
@Parth Gupta
Your input is wrong as there is no prime ( Except 5 ) that ends with 5 :)
It will be great if there are
It will be great if there are some more sample input and ouput sets.
why these answers are wrong. for the sample input
2
13
101
please clarify
Thanks in advance !!
Who said they are wrong? The
Who said they are wrong? The problem clearly says there can be multiple correct answers.
any hints for reducing time
any hints for reducing time limit??
You will not be given hints,
You will not be given hints, no.
Hi, on my laptop I am getting
Hi,
on my laptop I am getting correct answer for the 100's of examples I tried for at most 12 digits.But while submitting it says wrong answer.May I know what kind of input lead my program give wrong answer.
Thanks.
No, you may not :)
No, you may not :)
Hi, I have 3 doubts 1] for
Hi, I have 3 doubts
1] for input : ???0???
is the output : 1000003 correct ?
2] Do we have to specify "Output" <without the quote> in the answer?
3] can the hidden number in any test case be other than prime ? i.e. do we have to handle such cases? If yes then what to output for such case?
1) Of course it is.. why
1) Of course it is.. why wouldn't it be?
2) No. Just the solutions.
3) Read the last line of the output section.
Getting 'Wrong answer',
Getting 'Wrong answer', though i checked all cases, i can think of.
Any hint about corner cases ?
Wait until after the contest
Wait until after the contest has finished.
hmmmm shouldnt there be
hmmmm shouldnt there be approval for comments from the admin ?? ...what if i post my code here ..as in any case i am not gonna win .. :P
Then you would probably be
Then you would probably be disqualified from all future contests :)
hehehe
Now, as the contest is over,
Now, as the contest is over, I think someone can help me.
I am getting runtime error (SIGSEGV). Can the admin please let me know why I am getting this error?
My submission ID is 162741.
where can we get the
where can we get the solutions..
search for solutions in this
search for solutions in this page.
@Jyotesh - your program has a
@Jyotesh - your program has a few bugs in it. Try this as input:
2???????????7
???????????7
The first case your program prints out a number ending with 3; the second case it crashes.
@Admin, I also got 'Wrong
@Admin,
I also got 'Wrong answer' for this problem.
Can you please tell, for which case my solution failed.
For above input,
my output is
2
100000000019
100000000019
Submission ID: 168260
Submission ID: 168260
@Admin I was looking for
@Admin
I was looking for correct solution for this problem.
Found this ID: 165066
Copied the code and tried few test cases...
strange but it's not giving answer if i am giving "11??12??" as input, working fine for inputs like "????????"
...
Don't know how it's accepted...
No response after 2 days :(
No response after 2 days :(
Mohit, it's "about 15 test
Mohit, it's "about 15 test cases", not "at most".
One reason might be because
One reason might be because the code uses printf("%lld") to print the long long value. printf for long long usually gives incorrect output on my dev-cpp compiler but works correct on the codechef server. You can try modifiying printf to cout which should give u the right answers !!
@Michae, Ajay Thanks for
@Michae, Ajay
Thanks for response.
Is there any way, i can check my solution, after challenge is over for this problem ?
I don't see 'Submit' button on top of this page.
All problems are moved to the
All problems are moved to the practice area after a contest. Go <a href="http://www.codechef.com/problems/L3/">here</a>.
Whoops. That didn't work too
Whoops. That didn't work too well, but you got the address there.