fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool snt(int n) {
  5. if (n<2) return false;
  6. for (int i=2;i*i<=n;i++) {
  7. if (n%i==0) {
  8. return false;
  9. }
  10. }
  11. return true;
  12. }
  13.  
  14. int demcs(int n) {
  15. int d=0;
  16. while (n>0) {
  17. d++;
  18. n/=10;
  19. }
  20. return d;
  21. }
  22.  
  23. int main() {
  24. int n,k;
  25. cin >> n >> k;
  26. int m=n,d=demcs(n);
  27. if (k>=d) {
  28. cout << "a) 0" << endl;
  29. } else {
  30. for (int i=0;i<k;i++) {
  31. n/=10;
  32. }
  33. cout << "a) " << n << endl;
  34. }
  35. cout << "b) " << d << endl;
  36. m/=10;
  37. while (m>0 && !snt(m)) {
  38. m/=10;
  39. }
  40. if (m>0) {
  41. cout << "c) " << m;
  42. } else {
  43. cout << "c) KHONG THE";
  44. }
  45. }
Success #stdin #stdout 0s 5268KB
stdin
3079 2
stdout
a) 30
b) 4
c) 307