fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. const int TEN = 10;
  6. int n, first_digit, number = 0;
  7. cin >> n;
  8. int n_copy = n;
  9. while (n > 0) {
  10. first_digit = n % TEN;
  11. n /= TEN;
  12. }
  13. while (n_copy) {
  14. if ((n_copy % TEN) % first_digit == 0)
  15. ++number;
  16. n_copy /= TEN;
  17. }
  18. if (first_digit == 0) {
  19. cout << number;
  20. }
  21. else {
  22. cout << number - 1;
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5492KB
stdin
Standard input is empty
stdout
Standard output is empty