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

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


input and output is correct bt why wrong answer??
#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;
}
Users browsing this forum: No registered users and 0 guests