#include <iostream> #include <cmath> using namespace std; bool pierwsza(long long n) { if (n < 2) return false; if (n == 2) return true; for (long long i = 2; i<=sqrt(n); i++) if (n%i == 0) return false; return true; } int main() { long long input, right, left, potega=1; cin >>input; bool druga = false; do{ potega*=10; right = input % potega; left = input / potega; if ((input/(potega/10)) % 10 == 0) continue; if (pierwsza(left)==true && pierwsza(right)==true) druga = true; }while (left >= 10); if (druga) cout <<"TAK"; else cout <<"NIE"; 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 | #include <iostream> #include <cmath> using namespace std; bool pierwsza(long long n) { if (n < 2) return false; if (n == 2) return true; for (long long i = 2; i<=sqrt(n); i++) if (n%i == 0) return false; return true; } int main() { long long input, right, left, potega=1; cin >>input; bool druga = false; do{ potega*=10; right = input % potega; left = input / potega; if ((input/(potega/10)) % 10 == 0) continue; if (pierwsza(left)==true && pierwsza(right)==true) druga = true; }while (left >= 10); if (druga) cout <<"TAK"; else cout <<"NIE"; return 0; } |