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
#include <iostream>
#include <vector>
#include <random>
#include <cstdlib>
#include <time.h>
#include <math.h>

using namespace std;

bool IsPrime(long long candidate)
{
     for(long long i=2; i*i< candidate; ++i)
     {
          if(candidate % i == 0)
          {
               return false;
          }
     }
     return true;
}

long long Power(long long a, int b, long long result = 1)
{
     if(b == 0) return result;
     return Power(a, b-1, result*a);
}

int main()
{
     srand(time(NULL));
     long long input;
     bool allDone = false;

     cin >> input;
     for(int i=1; i<=log10(input); ++i)
     {
          //if(Modulo(input/Power(10, i-1), 10) != 0) cout << input/Power(10, i) << " " << Modulo(input, Power(10, i)) << "\n";
          if(input/Power(10, i-1) % 10 != 0 && IsPrime(input/Power(10, i)) && IsPrime(input % Power(10, i)))
          {
               allDone = true;
               break;
          }
     }
     if(allDone) cout << "TAK\n";
     else cout << "NIE\n";
}