PRI10


Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 512M

Problem type

Cho hai số nguyên \(a,b\). Tính tổng các số nguyên tố trong đoạn \([a,b]\).

Input

  • Dòng 1 chứa số nguyên \(T(T≤10^5\) ),là số bộ test.

  • \(T\) dòng tiếp theo, mỗi dòng chứa hai số nguyên \(a,b (1≤a≤b≤10^5) \)thể hiện yêu cầu của một bộ test.

Output

  • Ghi \(T\) dòng, mỗi dòng ghi một số nguyên là kết quả của test tương ứng.

Sample Input

2
1 20
10 20

Sample Output

77
60

Comments


  • 0
    Nguyen_Vu_Nhat_Truong  commented on Feb. 22, 2025, 9:23 a.m.

    include<bits/stdc++.h>

    define fr(i,a,b) for(int i=a;i<=b;i++)

    define frd(i,a,b) for(int i=a;i>=b;i++)

    define ll long long

    define Hkhoi ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

    using namespace std; int n,a[1000+3]; void doc() { cin>>n; fr(i,1,n) cin>>a[i]; } void xuly() { sort(a+1,a+n+1); int res=1, d=a[n]; for(int i=n-1;i>=1;i--) { if(d>0) { res++; d=min(d-1,a[1]); } } cout<<res; } int main() { Hkhoi; doc(); xuly(); return 0; }