a121. ่ณชๆ•ธๅˆไพ†ๅ›‰ 5/16/2025

่งฃๆณ•ไธ€ใ€็ชฎ่ˆ‰

โœ… ๅฎŒๆ•ดไปฃ็ขผ

่ฉ•ๅˆ†็ตๆžœ(ๅƒ่€ƒ) ๏ผš AC (0.1s, 348KB)

#include <bits/stdc++.h>
using namespace std;

bool isPrime(int x)
{
    if(x==1) return false;
    if(x==2) return true;
    if(x%2==0) return false;

    for(int i=3; i<=sqrt(x); i+=2){
        if(x%i==0) return false;
    }

    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b;
    while(cin >> a >> b){
        int n = 0;
        for(int i=a; i<=b; i++){
            if(isPrime(i)) n++;
        }
        cout << n << "\n";
    }
    
    return 0;
}