• LQDOJ
  • Trang chủ
  • Bài tập
  • Bài nộp
  • Thành viên
  • Kỳ thi
  • Nhóm
  • Giới thiệu
    • Máy chấm
    • Khóa học
    • Đề xuất ý tưởng
    • Đề xuất bài tập
    • Tools
    • Báo cáo tiêu cực
    • Báo cáo lỗi

Tiếng Việt

Tiếng Việt
English

Đăng nhập

Đăng ký

dex111222333444555

  • Giới thiệu
  • Bài tập
  • Bài nộp

Rating
-
Bài tập
39
Điểm
18984
Rating #
-
Điểm #
2830

Giới thiệu

include <iostream>

include <vector>

include <cmath>

using namespace std;

bool check(int n){
if (n < 2) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
for(int i = 3; i <= sqrt(n); i += 2){
if (n % i == 0) return false;
}
return true;
}

int main(){
int T; cin >> T;
while(T--){
int L, R, ans = 0; cin >> L >> R;
for(int i = L; i <= R; i++){
if (check(i)){
ans++;
}
}
cout << ans << endl;
}
}


«    »
Thứ 2
Thứ 3
Thứ 4
Thứ 5
Thứ 6
Thứ 7
CN
Ít
Nhiều

proudly powered by DMOJ| developed by LQDJudge team