Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string n, a, b;
  4. int c, d, x, y, z = 0;
  5. int main(){
  6. ios_base::sync_with_stdio(0);
  7. cin.tie(0);
  8. cout.tie(0);
  9. cin >> n;
  10. int p = n.size();
  11. do {
  12. x = 0;
  13. y = 0;
  14. for (int i = 0; i < p-1; i++) {
  15. a += n[i];
  16. c = stoi(a);
  17. if (c%10 == 0 || c%10 == 4 ||c%10 == 6 || c%10 == 8) {
  18. x = 1;
  19. break;
  20. }
  21. for (int j = 2; j < ceil(sqrt(c)); j++) {
  22. if (c % j == 0) {
  23. x = 1;
  24. break;
  25. }
  26. }
  27. }
  28. for (int i = p-1; i < n.size(); i++) {
  29. b += n[i];
  30. d = stoi(b);
  31. if (d == 0 || d%10 == 0 || d%10 == 4 ||d%10 == 6 || d%10 == 8) {
  32. y = 1;
  33. break;
  34. }
  35. for (int j = 2; j < ceil(sqrt(d)); j++) {
  36. if (d % j == 0) {
  37. y = 1;
  38. break;
  39. }
  40. }
  41. }
  42. if (x == 0 && y == 0) {
  43. z = 1;
  44. break;
  45. }
  46. a = "";
  47. b = "";
  48. p--;
  49. } while (p > 1);
  50. if (z == 1) {
  51. cout << "TAK";
  52. } else {
  53. cout << "NIE";
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement