//Brut #include <cstdio> bool check_if_prime(const unsigned long long n){ if(n == 0 || n == 1) return false; for(int i = 2; i*i <= n; i++) if(n % i == 0) return false; return true; } bool get_numbers_and_check(const unsigned long long n){ unsigned long long temp1 = n, temp2 = 0, pot = 1; while(temp1){ if(temp1 % 10 == 0){ temp1 /= 10; pot *= 10; continue; } temp2 *= pot; temp2 += temp1 % 10; temp1 /= 10; if(check_if_prime(temp1) == true && check_if_prime(temp2) == true) return true; pot *= 10; } return false; } int main() { unsigned long long n; scanf("%llu", &n); if(get_numbers_and_check(n)) printf("TAK\n"); else printf("NIE\n"); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | //Brut #include <cstdio> bool check_if_prime(const unsigned long long n){ if(n == 0 || n == 1) return false; for(int i = 2; i*i <= n; i++) if(n % i == 0) return false; return true; } bool get_numbers_and_check(const unsigned long long n){ unsigned long long temp1 = n, temp2 = 0, pot = 1; while(temp1){ if(temp1 % 10 == 0){ temp1 /= 10; pot *= 10; continue; } temp2 *= pot; temp2 += temp1 % 10; temp1 /= 10; if(check_if_prime(temp1) == true && check_if_prime(temp2) == true) return true; pot *= 10; } return false; } int main() { unsigned long long n; scanf("%llu", &n); if(get_numbers_and_check(n)) printf("TAK\n"); else printf("NIE\n"); return 0; } |