#include <iostream>
using namespace std;
bool pierwsza(long long liczba)
{
if(liczba<2)
{
return false;
}
else
{
for(int i=2;i*i<=liczba;i++)
{
if(liczba%i==0)
{
return false;
}
}
return true;
}
}
int main()
{
long long n,l,p,dziesiatki=10;
bool stop=false;
cin>>n;
if(n<22)
{
cout<<"NIE";
}
else
{
while(stop==false&&dziesiatki<=n)
{
l=n/dziesiatki;
p=n-(l*dziesiatki);
if(pierwsza(l)==true&&pierwsza(p)==true&&p>=dziesiatki/10)
{
stop=true;
cout<<"TAK";
}
dziesiatki=dziesiatki*10;
}
if(stop==false)
{
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 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <iostream> using namespace std; bool pierwsza(long long liczba) { if(liczba<2) { return false; } else { for(int i=2;i*i<=liczba;i++) { if(liczba%i==0) { return false; } } return true; } } int main() { long long n,l,p,dziesiatki=10; bool stop=false; cin>>n; if(n<22) { cout<<"NIE"; } else { while(stop==false&&dziesiatki<=n) { l=n/dziesiatki; p=n-(l*dziesiatki); if(pierwsza(l)==true&&pierwsza(p)==true&&p>=dziesiatki/10) { stop=true; cout<<"TAK"; } dziesiatki=dziesiatki*10; } if(stop==false) { cout<<"NIE"; } } return 0; } |
English