Submission
Status:
----------
Subtask/Task Score:
0/100
Score: 0
User: scoobydoobydoo
Problemset: จำนวนเฉพาะ (2560)
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-15 22:40:05
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define el << '\n'
bool isPrime (int x) {
if (x < 2) return false;
for (int i=2; i*i <= x; i++) {
if(x % i == 0) return false;
}
return true;
}
bool godPrime (int x) {
if (x < 2) return false;
if (x == 2 || x == 3) return true;
if (x % 2 == 0 || x % 3 == 0) return false;
for (int i=5; i*i <= x; i+=6) {
if (x % i == 0 || x % (i + 2) == 0) {
return false;
}
}
return true;
}
int value(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
return c - 'A' + 10;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for (int i=2; i<=n; i+=2) {
if (godPrime(i)) {
cout << i el;
}
if (i==2) i++;
}
//..........................................................
// int n;
// cin >> n;
// int size = 2*n - 1;
// int center = n - 1;
// for (int i=0; i<size; i++) {
// char letter = 'A' + abs(i - center);
// for (int j=0; j<size; j++) {
// if (i == j || i + j == size - 1) {
// cout << letter;
// } else {
// cout << ' ';
// }
// }
// cout << ' ';
// for (int k = 0; k<size; k++) {
// if (i == k || i + k == size - 1) {
// cout << '*';
// } else {
// cout << ' ';
// }
// }
// cout el;
// }
//..........................................................
// int base;
// string a, b;
// cin >> base >> a >> b;
// string digits = "0123456789ABCDEF";
// string answer;
// int i = (int)a.size() - 1;
// int j = (int)b.size() - 1;
// int carry = 0;
// while (i >= 0 || j >= 0 || carry > 0) {
// int sum = carry;
// if (i >= 0) {
// sum += value(a[i]);
// i--;
// }
// if (j >= 0) {
// sum += value(b[j]);
// j--;
// }
// answer += digits[sum % base];
// carry = sum / base;
// }
// reverse(answer.begin(), answer.end());
// size_t first = answer.find_first_not_of('0');
// if (first == string::npos) {
// cout << "0\n";
// } else {
// cout << answer.substr(first) << '\n';
// }
return 0;
}