#include <iostream> typedef int64_t number_t; inline bool potyczkowa(number_t x) { number_t y = x; int8_t digit; while (y > 0) { digit = y % 10; if (digit == 0 || x % digit != 0) { return false; } y /= 10; } return true; } int main() { std::ios_base::sync_with_stdio(false); number_t l, r; std::cin >> l >> r; number_t res = 0; for (number_t x = l; x < r; x++) { if (potyczkowa(x)) { res++; } } std::cout << res << std::endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <iostream> typedef int64_t number_t; inline bool potyczkowa(number_t x) { number_t y = x; int8_t digit; while (y > 0) { digit = y % 10; if (digit == 0 || x % digit != 0) { return false; } y /= 10; } return true; } int main() { std::ios_base::sync_with_stdio(false); number_t l, r; std::cin >> l >> r; number_t res = 0; for (number_t x = l; x < r; x++) { if (potyczkowa(x)) { res++; } } std::cout << res << std::endl; return 0; } |