fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool prime(int x) {
  5. int i = 2;
  6. if (x < 2) {
  7. return false;
  8. }
  9. while (i < x) {
  10. if (x % i == 0) {
  11. return false;
  12. }
  13. i++;
  14. }
  15. return true;
  16. }
  17.  
  18. int inverse(int x) {
  19. int t = 0;
  20. while (x) {
  21. t = t * 10 + x % 10;
  22. x /= 10;
  23. }
  24. return t;
  25. }
  26.  
  27. int main() {
  28. int x;
  29. cin >> x;
  30. cout << (prime(x) && inverse(prime(x)) ? "DA" : "NU");
  31. }
Success #stdin #stdout 0.01s 5320KB
stdin
31
stdout
DA