#include #include using namespace std; bool check3(unsigned long* num,const unsigned int start,const unsigned int end = 0); int main(){ unsigned long a; unsigned long b; cin >> a >> b; for (;a<=b;a++){ if (!(a%3) || check3(&a,1)) cout << a << endl; } } inline bool check3(unsigned long* num,const unsigned int start,const unsigned int end){ for (unsigned int d = start; d <= ((end) ? end : floor(log10(*num)) + 1); d++){ if ( 3 == floor(*num/pow(10,d-1)) - floor(*num/pow(10,d))*10) return true; } return false; }