Workspace ICPC 2025 - Vinh University

The exam is structured as a basic-level ICPC assessment.

Nhận xét Tham gia thảo luận bên dưới.
đã bình luận vào Tháng 10. 15, 2025, 6:11 p.m.

include <bits/stdc++.h>

using namespace std;

define nmax 10000000

bool a[nmax + 1]; void sang() { for (int i = 2; i <= nmax; i++) a[i] = true; a[0] = a[1] = false; for (int i = 2; i * i <= nmax; i++) { if (a[i]) { for (int j = i * i; j <= nmax; j += i) { a[j] = false; } } } }

bool check(int n) {

while (n &gt; 0) 
{
    if (!a[n]) return false;
    n /= 10;
}
return true;

}

int main() { ios::sync_with_stdio(false); cin.tie(nullptr); sang(); int l, r; cin >> l >> r; bool ok = false; for (int i = l; i <= r; i++) { if (check(i)) { cout << i << "\n"; ok = true; } } }