Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Kei
Problemset: จำนวนเฉพาะ (2560)
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-07 11:11:46
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool isprime(ll a){
if(a<2) return false;
if(a==2) return true;
ll d=2;
while(d*d<=a){
if(a%d==0) return false;
d++;
}
return true;
}
void solve(){
int n;
cin >> n;
if(n==2) return;
cout << 2 << '\n';
for(int i=1;i<n;i+=2){
if(isprime(i)) cout << i << '\n';
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}