10852 - Less Prime

Moderator: Board moderators

ibrahim wrote:I can't understand what the question is trying. Can anybody please explain it ?
How can 101 output is 53 ?

You are looking for a prime number x≤n, such that n%x is maximum. (and 101%53=48, the most you can get)

Martin Macko
A great helper

Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: 10852 input

ThanhNhan wrote:That the input for p10852 contains n < 100 is incorrect. Shouldn't it be fixed ?

I think, it should be fixed... At least in the problem statement...
Possibly, we could ask problemsetter to fix it...

Martin Macko
A great helper

Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Thanks, AC

ibrahim
Experienced poster

Posts: 149
Joined: Mon Feb 07, 2005 10:28 pm

How can it be solved in 0.000sec?

How can it be solved in 0.000sec?
Please give me some hit, thank you!
alecliu
New poster

Posts: 1
Joined: Thu Jun 01, 2006 9:27 am

10852 - Less Prime

I just checked the condition:
while(prime[j]*2<=n)
j++;
I thought that was enough.But got wrong answer.
Plz help.
Neli
New poster

Posts: 7
Joined: Thu May 03, 2007 8:35 am
Location: Sylhet

>>Neli
Ur solution is ok. so u should check the other parts of the code specially the prime generating part.
If u don't get any coz of getting WA then i think the best idea to recode it.
mmonish
Experienced poster

Posts: 109
Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST

caution: 10852 - Less Prime

input can be less than 100.
for input 1 & 2
just output -1;
others r according to ur (correct)algorithm.
Experienced poster

Posts: 136
Joined: Sat Nov 29, 2008 8:01 am

Re: caution: 10852 - Less Prime

input and output is correct bt why wrong answer??

Code: Select all
`#include<stdio.h>int main(){   int i,b,flag,a,c,test,g,p;   scanf("%d",&test);   while(test--)   {      scanf("%d",&c);      a=2;      g=0;      p=(c/2)+1;      for(b=p;b<=c;b++)      {         flag=0;         for(i=2;i<=(b/2);i++)            if((b%i)==0)            {               flag=1;               break;            }         if(flag==0)         {            printf("%d\t",b);            g++;         }         if(g==1)            break;      }      printf("\n");   }return 0;}`
sayed
New poster

Posts: 2
Joined: Tue Sep 01, 2009 11:47 am