28 lines
500 B
C++
28 lines
500 B
C++
#include<iostream>
|
|
using namespace std;
|
|
bool pan(long long n){
|
|
if(n<2){
|
|
return 0;
|
|
}
|
|
for(int i=2;i*i<=n;i++){
|
|
if(n%i==0){
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
int main(){
|
|
long long n,a=10,b,ans=1000000000000000;
|
|
cin>>n;
|
|
for(int i=10;a>=10;i*=10){
|
|
a=n/i;
|
|
b=n%i;
|
|
if(a+b<ans&&pan(a+b)==1){
|
|
ans=a+b;
|
|
}
|
|
}
|
|
if(ans==1000000000000000){
|
|
ans=-1;
|
|
}
|
|
cout<<ans;
|
|
} |