fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5.  
  6. int main() {
  7. int a;
  8. cin >> a;
  9. int copyA = a;
  10. int reverseA = 0;
  11. while (a) {
  12. reverseA = reverseA * TEN + a % TEN;
  13. a /= TEN;
  14. }
  15. int divizor = 2, estePrim = 1;
  16. while (divizor < copyA) {
  17. if (copyA % divizor == 0) {
  18. estePrim = 0;
  19. }
  20. ++divizor;
  21. }
  22. if (copyA == 1) {
  23. estePrim = 0;
  24. }
  25. int divizorReverseA = 2, estePrimReverseA = 1;
  26. while (divizorReverseA < reverseA) {
  27. if (reverseA % divizorReverseA == 0) {
  28. estePrimReverseA = 0;
  29. }
  30. ++divizorReverseA;
  31. }
  32. if (reverseA == 1) {
  33. estePrimReverseA = 0;
  34. }
  35. if ((estePrim == 1) && (estePrimReverseA == 1)) {
  36. cout << "DA" << endl;
  37. } else {
  38. cout << "NU" << endl;
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
NU