×

# include<stdio.h>

int main() { int t,a,b,i,j,k,ct; scanf("%d",&t); for(i=1;i<=t;i++) { scanf("%d%d",&a,&b);

  for(j=a;j<=b;j++)
{ for(k=2,ct=0;k<=j/2;k++)
{if(j%k==0)
ct++;}

if(ct==0)
printf("%d",j);


}

printf("\n"); } return 0; }

2★robof1
1
accept rate: 0%

(06 Sep '17, 09:26) 2★

 0 Please share the question link. From the code it looks like you are trying to find all the primes between a and b. If so, your approach will time out. Just give a large a and b and run your code on your system. You can see how long it takes. Then study segmented sieve and implement that. If you don't know sieve, start with sieve-of-eratosthenes and do a couple of problems from that. Then move to segmented sieve. answered 06 Sep '17, 10:43 893●2●11●34 accept rate: 10%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,718
×1,134
×250

question asked: 06 Sep '17, 09:24

question was seen: 238 times

last updated: 06 Sep '17, 10:43