fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. bool snt( int n ){
  5. if(n < 2) return 0;
  6. for(int i=2 ; i<=sqrt(n) ; i++){
  7. if(n % i == 0) return 0;
  8. }
  9. return 1;
  10. }
  11.  
  12. bool tongChuSo ( int n ){
  13. if(!snt(n)) return 0;
  14. int sum = 0;
  15. while( n>0){
  16. sum += n % 10;
  17. n /= 10;
  18. }
  19. if(!snt(sum)) return 0;
  20. return 1;
  21. }
  22.  
  23.  
  24. int main() {
  25. int n;
  26. cin>>n;
  27. if(tongChuSo(n)) cout<<"YES."<<endl;
  28. else cout<<"NO"<<endl;
  29. return 0;
  30. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
NO