Editorial for Bedao Grand Contest 03 - THREE
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Code mẫu
#include <bits/stdc++.h> using namespace std; const int MX = 1E6 + 5; int q; long long u; bool pr[MX]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); freopen("THREE.inp", "r", stdin); freopen("THREE.out", "w", stdout); for (int i = 2; i < MX; i++) { if (!pr[i]) { for (int j = i * 2; j < MX; j += i) { pr[j] = true; } } } pr[1] = true; cin >> q; while (q--) { cin >> u; int sr = sqrt(u); if (1LL * sr * sr == u && !pr[sr]) { cout << "1\n"; } else { cout << "0\n"; } } }
Comments