Created
October 17, 2019 12:15
-
-
Save trhgquan/4b3687adb70f2482713987a737d862f1 to your computer and use it in GitHub Desktop.
More algorithm at https://github.com/trhgquan/CPP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* https://www.spoj.com/problems/NUB04/ | |
* Code by @trhgquan - https://github.com/trhgquan | |
*/ | |
#include <iostream> | |
#define lli long long int | |
bool isPrime(lli a) { | |
if (a == 0 || a == 1) return false; | |
if (a == 2) return true; | |
for (lli i = 2; i * i <= a; ++i) | |
if (a % i == 0) return false; | |
return true; | |
} | |
int main() { | |
std::ios_base::sync_with_stdio(false); | |
std::cin.tie(NULL); | |
lli i; | |
while (std::cin >> i) { | |
if (isPrime(i)) std::cout << "YES" << std::endl; | |
else std::cout << "NO" << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment