提交时间:2024-07-21 20:53:19

运行 ID: 158112

#include <iostream> #include <vector> using namespace std; bool isBinarySemiPrime(int n) { if (n <= 0) return false; for (int i = 0; (1 << i) <= n; ++i) { for (int j = i + 1; (1 << j) <= n; ++j) { if (((1 << i) + (1 << j)) == n) { return true; } } } return false; } int main() { int t; cin >> t; vector<int> results; while (t--) { int n; cin >> n; if (isBinarySemiPrime(n)) { results.push_back(1); // 1 for 'yes' } else { results.push_back(0); // 0 for 'no' } } for (int result : results) { cout << (result ? "yes" : "no") << endl; } return 0; }