Simple Prime (Contest)
Time Limit: 2 sec
Memory Limit: 128000 kB
Problem Statement
Let's define P[i] as the ith Prime Number. Therefore, P[1]=2, P[2]=3, P[3]=5, so on.
Given two integers L, R (L<=R), find the value of P[L]+P[L+1]+P[L+2]...+P[R].
Input
The first line of the input contains an integer T denoting the number of test cases.
The next T lines contain two integers L and R.
Constraints
1 <= T <= 50000
1 <= L <= R <= 50000
Output
For each test case, print one line corresponding to the required value
Comments
Leave a comment