Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- string n, a, b;
- int c, d, x, y, z = 0;
- int main(){
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin >> n;
- int p = n.size();
- do {
- x = 0;
- y = 0;
- for (int i = 0; i < p-1; i++) {
- a += n[i];
- c = stoi(a);
- if (c%10 == 0 || c%10 == 4 ||c%10 == 6 || c%10 == 8) {
- x = 1;
- break;
- }
- for (int j = 2; j < ceil(sqrt(c)); j++) {
- if (c % j == 0) {
- x = 1;
- break;
- }
- }
- }
- for (int i = p-1; i < n.size(); i++) {
- b += n[i];
- d = stoi(b);
- if (d == 0 || d%10 == 0 || d%10 == 4 ||d%10 == 6 || d%10 == 8) {
- y = 1;
- break;
- }
- for (int j = 2; j < ceil(sqrt(d)); j++) {
- if (d % j == 0) {
- y = 1;
- break;
- }
- }
- }
- if (x == 0 && y == 0) {
- z = 1;
- break;
- }
- a = "";
- b = "";
- p--;
- } while (p > 1);
- if (z == 1) {
- cout << "TAK";
- } else {
- cout << "NIE";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement