10852 - Less Prime

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

Moderator: Board moderators

Postby Martin Macko » Thu Aug 18, 2005 8:49 pm

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)
User avatar
Martin Macko
A great helper
 
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: 10852 input

Postby Martin Macko » Thu Aug 18, 2005 8:53 pm

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...
User avatar
Martin Macko
A great helper
 
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Postby ibrahim » Fri Aug 19, 2005 7:37 am

Thanks, AC
User avatar
ibrahim
Experienced poster
 
Posts: 149
Joined: Mon Feb 07, 2005 10:28 pm
Location: Northern University, Bangladesh

How can it be solved in 0.000sec?

Postby alecliu » Thu Jun 01, 2006 9:30 am

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

Postby Neli » Thu May 24, 2007 11:22 am

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

Postby mmonish » Thu May 24, 2007 12:05 pm

>>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

Postby sazzadcsedu » Fri Feb 27, 2009 11:35 pm

input can be less than 100.
for input 1 & 2
just output -1;
others r according to ur (correct)algorithm.
sazzadcsedu
Experienced poster
 
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.

Re: caution: 10852 - Less Prime

Postby sayed » Wed Oct 14, 2009 8:24 am

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
Location: Bangladesh

Previous

Return to Volume CVIII

Who is online

Users browsing this forum: No registered users and 0 guests