You are looking for a prime number x≤n, such that n%x is maximum. (and 101%53=48, the most you can get)ibrahim wrote:I can't understand what the question is trying. Can anybody please explain it ?
How can 101 output is 53 ?
10852 - Less Prime
Moderator: Board moderators
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
Re: 10852 input
I think, it should be fixed... At least in the problem statement...ThanhNhan wrote:That the input for p10852 contains n < 100 is incorrect. Shouldn't it be fixed ?
Possibly, we could ask problemsetter to fix it...
How can it be solved in 0.000sec?
How can it be solved in 0.000sec?
Please give me some hit, thank you!
Please give me some hit, thank you!
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.
while(prime[j]*2<=n)
j++;
I thought that was enough.But got wrong answer.
Plz help.
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
caution: 10852 - Less Prime
input can be less than 100.
for input 1 & 2
just output -1;
others r according to ur (correct)algorithm.
for input 1 & 2
just output -1;
others r according to ur (correct)algorithm.
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
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;
}
Re: 10852 - Less Prime
This was quite misleading / confusing.CDiMa wrote:Look out for input values under 100.
On the input, the problem statement clearly states
There really are no "gotchas". It's all quite straightforward.For each test case, there is a line with a number N, 100 ? N ? 10000.
Re: caution: 10852 - Less Prime
You're nearly there.sayed wrote: input and output is correct bt why wrong answer??
Change
Code: Select all
printf("%d\t",b);
Code: Select all
printf("%d",b);