#include #include using namespace std; bool find3(int x) { string str = to_string(x); return str.find("3",0)!=string::npos; } int main() { int A, B; cin >> A >> B; for(int i=A; i<=B; i++) { if( (i % 3 == 0 ) || // 3で割り切れる (find3(i)) ) { // 3が含まれる cout << i << endl; } } return 0; }