fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int snt(int n){
  4. if(n<2) return 0;
  5. for(int i=2;i*i<=n;i++){
  6. if(n%i==0) return 0;
  7. }
  8. return 1;
  9. }
  10. int main(){
  11. int k,x;
  12. cin>>k>>x;
  13. bool a=true;
  14. int dem=0;
  15. int luu=k;
  16. if(!snt(k)) a=false;
  17. while(k!=0){
  18. dem++;
  19. k/=10;
  20. }
  21. if(dem!=x) a=false;
  22. int tong=0;
  23. while(luu!=0){
  24. tong+=(luu%10);
  25. if(!snt(luu%10)) a=false;
  26. luu/=10;
  27. }
  28. if(!snt(tong)) a=false;
  29. if(a) cout<<"YES";
  30. else cout<<"NO";
  31. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
NO