#include #include using namespace std; inline int powi(int n, int m) { int product = 1; for (int i = 0; i < m; i++) { product *= n; } return product; } inline bool check_three(int n) { int digit, unit; if (n % 3 == 0) return true; digit = log10(n) + 1; for (int i = 0; i < digit; i++) { unit = n % powi(10, i+1) / powi(10, i); if (unit == 3) return true; } return false; } int main(int argc, char const* argv[]) { int A, B; cin >> A >> B; for (int i = A; i < B+1; i++) { if (check_three(i)) cout << i << endl; } return 0; }