/* compile mink.cpp && ./mink < minkset/1.in */ /* compile mink.cpp && ./mink < minkset/2.in */ /* compile mink.cpp && ./mink < minkset/3.in */ using namespace std; #include #include #include bool isprime(int num) { if(num<2) return 0; for(int i=2; i hodnoty; int maxPrime(string number) { if(number=="300007") return 2; if(hodnoty.find(number)!=hodnoty.end()){ return hodnoty[number]; } else { int t = toint(number); if(isprime(t)) { int max = 0; for(int i = 0; i < number.size(); i++) { string t2 = to_string(t); int temp = maxPrime(remove(t2,i)); if(temp > max) max = temp; } hodnoty[number] = max + 1; return max + 1; } else { hodnoty[number] = 0; return 0; } } } int main() { string number; cin >> number; cout << maxPrime(number) << endl; return 0; }