fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int ok1(int k, int n){
  5. int cnt = 0;
  6. while(k!=0){
  7. ++cnt;
  8. k /= 10;
  9. }
  10. if(cnt == n) return 1;
  11. else return 0;
  12. }
  13.  
  14. int ok2(int k){
  15. if(k<2) return 0;
  16. for(int i = 2; i <= sqrt(k); i++){
  17. if(k%i==0) return 0;
  18. }
  19. return 1;
  20. }
  21.  
  22. int ok3(int k){
  23. int sum = 0;
  24. while(k!=0){
  25. sum += k % 10;
  26. k /= 10;
  27. }
  28. if(ok2(sum)) return 1;
  29. else return 0;
  30. }
  31.  
  32. int ok4(int k){
  33. while(k!=0){
  34. int x = k % 10;
  35. if(ok2(x)==0) return 0;
  36. k /= 10;
  37. }
  38. return 1;
  39. }
  40.  
  41. int main(){
  42. int k, n;
  43. cin >> k >> n;
  44. if(ok1(k,n) && ok2(k) && ok3(k) && ok4(k)) cout << "Yes";
  45. else cout << "No";
  46.  
  47.  
  48. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
No