题解 | #牛牛的素数判断#
牛牛的素数判断
https://www.nowcoder.com/practice/81c8387f72824cceb5c955e3dbfd2882
#include <ios> #include <iostream> using namespace std; bool isPrime(int num) { bool flag = true; for(int i = 2; i * i <= num; i++) { if(num % i == 0) { flag = false; break; } } return flag; } int main() { int n; cin >> n; int num; while(cin >> num) { cout << boolalpha << isPrime(num) << endl; } } // 64 位输出请用 printf("%lld")