#include <bits/stdc++.h> using namespace std; bool czyPierwsza(long long x) { for (int i = 2; i*i <= x; i++) { if (x%i == 0) return false; } return true; } int main() { string x; cin>>x; for (int i = 1; i < x.length(); i++) { if (x[0] != '0' && x[i] != '0') if (czyPierwsza(stol(x.substr(0,i))) && czyPierwsza(stol(x.substr(i, x.length() - 1)))) { // cout<<x[0]<<" "<<x[i]<<endl; cout<<"TAK"; // cout<<x.substr(0, i)<<" "<<x.substr(i, x.length() - 1)<<endl; return 0; } // cout<<x.substr(0, i)<<" "<<x.substr(i, x.length() - 1)<<endl; } 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 | #include <bits/stdc++.h> using namespace std; bool czyPierwsza(long long x) { for (int i = 2; i*i <= x; i++) { if (x%i == 0) return false; } return true; } int main() { string x; cin>>x; for (int i = 1; i < x.length(); i++) { if (x[0] != '0' && x[i] != '0') if (czyPierwsza(stol(x.substr(0,i))) && czyPierwsza(stol(x.substr(i, x.length() - 1)))) { // cout<<x[0]<<" "<<x[i]<<endl; cout<<"TAK"; // cout<<x.substr(0, i)<<" "<<x.substr(i, x.length() - 1)<<endl; return 0; } // cout<<x.substr(0, i)<<" "<<x.substr(i, x.length() - 1)<<endl; } cout<<"NIE"; return 0; } |